I have a mysql table that stores customer transaction information. I want to sum column name "total" --which has values like this: $253.20-- only where the value of another column is "mossa01".
For this, I passed the variable to the code via url and trimmed it. I then used the following statement:
With this effort, I get the following error:
$client = @$_GET["q"] ;
$trimmed = trim($client); //trim whitespace from the stored variable
$res=mysql_query('SELECT SUM(SUBSTRING(`total`,2)) AS `total` FROM `billofservice` where clientID like "$trimmed" ');
if($result == false)
user_error("Query failed: " . mysql_error() . "<br />\n$res");
if(mysql_num_rows($result) == 0)
echo "<p>Sorry, no rows were returned by your query.</p>\n";
// die("Error: ".mysql_error());
$row = mysql_fetch_assoc($res);
echo "Total income earned from this client to date is ";echo"$";echo($row['total']);
May I request some assistance?
Notice: Query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #3' at line 1
Resource id #3 in C:\Apache\htdocs\andy\invoicehistory.php on line 80