Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
ok, first thing, "print" the query sent to the db, and try to execute it directly in the db.
If there is an error, mysql will tell you exactly what is wrong (which php simply don't do).
You can go a bit further in your db error management to show you the error message returned by mysql and the query sent, with something like this:
PHP Code:
<?php $price_code=$_REQUEST['price_code']; $price=$_REQUEST['price']; $description=$_REQUEST['description']; echo "$price_code"; echo"$price"; echo"$description"; ################################################## #Open database # ################################################## include("connect.php"); ################################################## #Run Query # ################################################## $query = "UPDATE price SET price_code = '$price_code', Price = '$price', Description = '$description' WHERE price_code = '$price_code'"; $result = mysql_query($query,$db); if($result===FALSE){ print "<pre>$query<br/>".mysql_error()."</pre>"; die(); }
$query = "select * from price"; $result = mysql_query($query,$db); if($result===FALSE){ print "<pre>$query<br/>".mysql_error()."</pre>"; die(); } $nrows = mysql_num_rows($result); ?> <table width="48%" border="1" align="center" bordercolor="#000000" bgcolor="#CCCCCC"> <tr> <td><div align="center"><b>Price Code</b></div></td> <td><div align="center"><b>Description</b></div></td> <td><div align="center"><b>Price</b></div></td> </tr> <?php ################################################## #Extract and place data in table # ################################################## $row=0; while($row < $nrows) { $price_code = mysql_result($result,$row,"price_code"); $description = mysql_result($result,$row,"description"); $price = mysql_result($result,$row,"price"); echo " <tr> <td>$price_code</td> <td>$description</td> <td>$price</td> </tr> "; $row++; } ?>
By the way, your update is a bit strange, as you seem to update the value of price_code with the same value than the one that was already there...
Are you sure it's what you want ? Or is it just an copy/paste mistake ?
__________________
Only a biker knows why a dog sticks his head out the window.
Last edited by tripy; 05-26-2009 at 11:48 AM..
|