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