Page 2 of 2

Re: update sql not updating

Posted: Fri Jan 16, 2015 10:16 am
by jonnyfortis
Celauran wrote:
jonnyfortis wrote:
Celauran wrote:

Code: Select all

$result=mysql_query($query);
or die(mysql_error());
You needed the ; after mysql_query() when the next line was commented out. Now you need to put it back.
like this??
No. You're getting the error because

Code: Select all

or die(mysql_error());
is not a valid statement. You need

Code: Select all

$result=mysql_query($query) or die(mysql_error());
brilliant. that done it, thanks for your help. i see what i done, thanks again

Re: update sql not updating

Posted: Sun Jan 18, 2015 1:34 pm
by jonnyfortis
i have just noticed something. even though this works, should my query not include a reference to the database connection

Code: Select all

$result=mysql_query($UpdateQuery) or die(mysql_error());
should be

Code: Select all

$result=mysql_query($UpdateQuery, $wiz) or die(mysql_error());

Re: update sql not updating

Posted: Sun Jan 18, 2015 4:39 pm
by Celauran
As per the manual, it's optional. http://php.net/manual/en/function.mysql-query.php

Your code shouldn't be using mysql_query, and definitely shouldn't have die statements in it.

Re: update sql not updating

Posted: Mon Jan 19, 2015 3:15 am
by jonnyfortis
Celauran wrote:As per the manual, it's optional. http://php.net/manual/en/function.mysql-query.php

Your code shouldn't be using mysql_query, and definitely shouldn't have die statements in it.
sorry bit confused, this is for another UPDATE statement to update stock, this is working but i wanted to know if it needed to included the database, as you say its optional.

Code: Select all

if ($row_rsUpdateStock['TransactResult'] == 'Completed')  {  
// UPDATE THE DATABASE      

$oldStock = $row_rsUpdateStock['Stock'];
$stockSold = $row_rsUpdateStock['Quantity'];
$newStock = $row_rsUpdateStock['Stock'] - $row_rsUpdateStock['Quantity'];
$SKU = $row_rsUpdateStock['SKU'];

$UpdateQuery="UPDATE wiz_Stock SET Stock = '$newStock' WHERE wiz_Stock.SKU = '$SKU'";

$result=mysql_query($UpdateQuery);
$result=mysql_query($UpdateQuery) or die(mysql_error());

}