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());

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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; 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.