Jump to content

[SOLVED] UPDATE problem with PHP variable.... help please


HelpMe1985

Recommended Posts

hi,

 

i am trying to UPDATE a table accounts with a php variable i have created but i keep getting an error "Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\wamp1\www\test5\balance.php on line 159

Error:"

 

this is the out put i get :

 

Weekly Total=6.00

Weekly Total + Delivery Charge=6.70

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\wamp1\www\test5\balance.php on line 159

Error: 

 

 

This is my code :

 

echo "<br>";
echo "Weekly Total=";
$weeklyTotal=$dailyTotal+$satTotal+$sunTotal;
printf ("%01.2f", $weeklyTotal);
echo "<br>";
echo "Weekly Total + Delivery Charge=";
$deTotal=$weeklyTotal+0.70;
printf ("%01.2f", $deTotal);



mysql_query("UPDATE accounts SET WeeklyCharge = '$deTotal' WHERE CustomerID='2'", $con) or die('Error: '.mysql_error());

try

mysql_query("UPDATE accounts SET WeeklyCharge = '".$deTotal."' WHERE CustomerID='2'", $con) or die('Error: '.mysql_error());

 

if the error is the query, here goes some solution

 

between " and ", any insert of variable must be declared closing ", adding a dot . putting the $variable, another dot. and reopen "

 

i.e.:

$name = "felipeebs";

"this is ".$name."!"

 

returns:

this is felipeebs

hi,

 

i tried changing it to

mysql_query("UPDATE accounts SET WeeklyCharge = '".$deTotal."' WHERE CustomerID='2'", $con) or die('Error: '.mysql_error());

and i still get the same erorr

 

Are you saying i need to change this $deTotal=$weeklyTotal+0.70; 

did you try just

 

mysql_query("UPDATE accounts SET WeeklyCharge = '".$deTotal."' WHERE CustomerID='2'");

 

maybe without some stuff it goes on... the simple way

 

of the same error continues, check your mysql table and send me the mysql_error returned

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.