Run php query on mysql - phpquery

I developed a small script to update some fields in two tables. The query run with no error, but for any reason nothing happen on these fields. I'm sure that something are omittedd by me, but I don't know what. Any idea?
<?php
//connection to the database
$connect=mysql_connect("localhost","xxxxxx","xxxxxxxxx") or
die("Unable to Connect"); echo ("Connected to server<br>");
//select a database to work with
mysql_select_db("xxxxxxxx") or die("Could not open the db"); echo ("Connected to database<br>");
//execute the SQL query tu update Price taxes on Products
$sql= "UPDATE pslpn_product SET id_tax_rules_group='68'";
$sql= "UPDATE pslpn_product_shop SET id_tax_rules_group='68'";
or die ('Could not update data: ' . mysql_error());
//close the connection
echo ("Finalizado<br>")
?>

If you forget to add WHERE clause, it will update all rows in the table.
UPDATE table_name SET field = value WHERE id = something -- or else

You forgot to execute your statement.
The mysql_connect() extension is deprecated. Use the MySQLi or PDO_MySQL extension instead: When should I use MySQLi instead of MySQL?
With mysqli you can execute a query like this:
if ($connect->query($sql) === TRUE) {
echo “Updated";
} else {
echo "Error " . $connect->error;
}
Read more: http://www.w3schools.com/php/php_mysql_update.asp

Related

Create a {if} statement in WHMCS

Im trying to create a specific IF statement on the clientareaproductdetails.tpl file in WHMCS - bottom line i'm trying to display some text on a page depending on the product the customer is looking at.
So this is what I tried (which does not work)
{if $id == '17'} something {else} nothing {/if}
So if the product ID = 17 then display 'something' otherwise display 'nothing.
Any ideas if/how this is possible?
Thanks in advance.
H
If by product id, you mean the package id, then it explains why your code didn't work. $id variable is for service id.
To achieve what you want, Add a hook file (say: custom_product_message.php) to includes/hooks/ folder.
Then add the following code:
<?php
add_hook('ClientAreaProductDetailsOutput', 1, function($service) {
if (!is_null($service)) {
if ($service['service']->packageId == 17) {
return "something";
} else {
return 'nothing';
}
}
return '';
});
The idea is to use ClientAreaProductDetailsOutput hook to display a text in the clientarea productdetails page.

Show Sharepoint incomplete surveys

I have created Sharepoint survey with "Page Separator" type questions. But, even I am farm admin, I am unable to view responses of an incomplete survey. I need to show total number of participant and how many of them complate survey, how many of them incomplete.
I have run this PowerShell. It does not work me, because $unPublishedEntries.Count is always zero
$unPublishedEntries.Count=0
$survey.ItemCount=56
$survey.Items.Count=3
$web = Get-SPWeb "http://portal.tracy.com/sites/GD/"
$survey = $web.lists["Survey"]
$unPublishedEntries = $survey.Items | ? {-not $_.HasPublishedVersion}
Write-Host "Surveys in list: " $survey.ItemCount
Write-Host "Of which entries are incomplete: " $unPublishedEntries.Count
Foreach ($entry in $unPublishedEntries)
{
Write-Host $entry["Author"]
}
Why I can not see (56-3) 53 users?
Also, I have run this query to check database
[sql query][1]
But, "tp_level = 255" shows deleted surveys too. If I try "tp_level = 1" it shows complated surveys, but it include deleted surveys too.
Is there any solution?
Hi you need to run sql query
This Solution work for me :
http://yasingokhanyuksel.blogspot.com.tr/2015/11/incomplete-surveys-in-sharepoint.html
Thanks

Zend_Auth: Join Query Issue

I'm a new guy for zendframework. i am facing zend auth join query issue..
Here I attach my zend_auth login sample code.
My login information's are stored in two tables. I mean email address in separate table and password separate. Here I was try to join my table, but I am getting Following error...
Message: The supplied parameters to Zend_Auth_Adapter_DbTable
failed to produce a valid sql statement, please check table and column
names for validity.
Please advise me.
My code is here...
$authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter());
$authAdapter->setTableName(array('users','details'))
->setIdentityColumn('name')
->setCredentialColumn('pwd');
$name = 'test';
$pwd = '123';
$authAdapter->setIdentity($name)
->setCredential($pwd);
$select = $authAdapter->getDbSelect();
$select->where('pwd = 123')
->joinLeft( array('d' => 'details'),'d.id = users.id');
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($authAdapter);

Updating schema for one entity without deleting everything else

When I run a schema update it successfully updates the schemas for my entities, but if there are any 'non-doctrine' tables in the database it deletes them. Unfortunately, these other tables are required for the 3rd party CMS I'm using.
Is there a way to tell doctrine to update the schema for certain entities (or all of them) without deleting anything else?
Below is my existing update code. The $classes array contains all the meta data for entity classes found in several different plugins.
//$em is an instance of EntityManager
//Psuedo Code
$classes = array(
$em->getClassMetadata('class1'),
$em->getClassMetadata('class2'),
$em->getClassMetadata('class3'),
$em->getClassMetadata('class4'),
$em->getClassMetadata('class5'),
);
//Real Code
$st = new Doctrine\ORM\Tools\SchemaTool( $em );
if ($classes)
$st->updateSchema($classes);
This gets all of the update sql but parses out any drop statements:
$sql = $st->getUpdateSchemaSql( $classes );
$count = count($sql);
for($i=0; $i<$count; $i++)
{
if(substr($sql[$i], 0, 4) == 'DROP')
unset($sql[$i]);
}
foreach($sql as $statement)
{
$em->getConnection()->exec( $statement );
}
You could run the schema tool with --dump-sql instead of --force, copy and paste the output from --dump-sql and run it on your database manually (of course removing the DROP statements for the tables you want to preserve.)

Doctrine2 how to see a generated createQuery SQL Text (symfony2)

I would like to get the 'real' SQL Query doctrine is passing to the SQL Server:
<?php
$em = $this->getDoctrine()->getEntityManager();
$myQuery = $em->createQuery('SELECT v FROM ....... v');
echo $myQuery->???????
?>
What I must to write instead of ???????? characters ?
I have tried with getSQLQuery() and with getSQL() but no luck for now.
Thanks..
You were almost there, it's getSql, not getSQL:
$myQuery->getSql()
You could try this:
$myQuery->getResult();
See if it helps
$myQuery->getDql();