Jump to content

query error


grlayouts

Recommended Posts

HI again, ok i have a code which should update the price of a product depending on how many there are.

 

 

everything works apart from the update price, last two lines... any idea's?

 

<?
include('config.php');
$sql = "SELECT COUNT(`drugs`) FROM `players`";
$result = mysql_query($sql) or die(mysql_error());
$num_drugs = mysql_result($result,0);
$sql2 = "SELECT COUNT(`steaks`) FROM `players`";
$result2 = mysql_query($sql2) or die(mysql_error());
$num_steaks = mysql_result($result2,0);
mysql_query('UPDATE players SET drugs = drugs + (drugfact*20), dpayout = (drugfact*20), steaks = steaks + (steakhouse*22), spayout = (steakhouse*22);');
mysql_query('UPDATE players SET credits = credits - (employees*wages)');
mysql_query('UPDATE price SET drugs = 10000 / (.$num_steaks)');
mysql_query('UPDATE price SET steaks = 20000 / (.$num_steaks)');

?>

Link to comment
https://forums.phpfreaks.com/topic/78115-query-error/
Share on other sites

it was for the echo i had. either way with or without the . is still doesn't work

 

Well you are no longer echo'ing anything, so why is the dot still in your query?

 

Usually when you try and fix a problem, this applies to all problem-solving and not just programming, the more information you have about the problem the easier it is to solve.  Until you get it resolved, change your code to give you more information:

$sql = 'UPDATE price SET drugs = 10000 / (.$num_steaks)';
mysql_query($sql) or
  die($sql . ' : ' . mysql_error());
$sql = 'UPDATE price SET steaks = 20000 / (.$num_steaks)';
mysql_query($sql) or
  die($sql . ' : ' . mysql_error());

Link to comment
https://forums.phpfreaks.com/topic/78115-query-error/#findComment-395333
Share on other sites

MySQL and PHP treat quotes differently.

 

Maybe try this:

 

<?php
mysql_query("UPDATE price SET drugs = 10000 / ($num_steaks)");
mysql_query("UPDATE price SET steaks = 20000 / (.$num_steaks)");
?>

 

Changing 'single quotes' to "double quotes".. ive heard that you cant use $open_vars in 'single quotes'

Link to comment
https://forums.phpfreaks.com/topic/78115-query-error/#findComment-395426
Share on other sites

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.