HelpMe1985 Posted July 18, 2008 Share Posted July 18, 2008 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()); Quote Link to comment https://forums.phpfreaks.com/topic/115471-solved-update-problem-with-php-variable-help-please/ Share on other sites More sharing options...
felipeebs Posted July 18, 2008 Share Posted July 18, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/115471-solved-update-problem-with-php-variable-help-please/#findComment-593600 Share on other sites More sharing options...
HelpMe1985 Posted July 18, 2008 Author Share Posted July 18, 2008 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; Quote Link to comment https://forums.phpfreaks.com/topic/115471-solved-update-problem-with-php-variable-help-please/#findComment-593606 Share on other sites More sharing options...
felipeebs Posted July 18, 2008 Share Posted July 18, 2008 what is the exact line that returns an error? (post it, please) Quote Link to comment https://forums.phpfreaks.com/topic/115471-solved-update-problem-with-php-variable-help-please/#findComment-593611 Share on other sites More sharing options...
HelpMe1985 Posted July 18, 2008 Author Share Posted July 18, 2008 LINE 159 is the query this line: mysql_query("UPDATE accounts SET WeeklyCharge = '$deTotal' WHERE CustomerID='2'", $con) or die('Error: '.mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/115471-solved-update-problem-with-php-variable-help-please/#findComment-593614 Share on other sites More sharing options...
felipeebs Posted July 18, 2008 Share Posted July 18, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/115471-solved-update-problem-with-php-variable-help-please/#findComment-593622 Share on other sites More sharing options...
HelpMe1985 Posted July 18, 2008 Author Share Posted July 18, 2008 that worked thank you Quote Link to comment https://forums.phpfreaks.com/topic/115471-solved-update-problem-with-php-variable-help-please/#findComment-593630 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.