Jump to content

Won't update, just refreshes..


Bullet

Recommended Posts

I am currently making a "Inventory" page, where you can equip a item.

 

Lets start of with the PHP:

 

$use=$_GET['use'];

$id=$_GET['id'];

 

 

if(($use) && ($id)){

$poo=mysql_query("SELECT * FROM inventory WHERE type='House' AND id='$id' AND username='$username'");

$rows=mysql_num_rows($poo);

if($rows == 0){

print "<p class='warning'>Error. There is no such house please try again.<META HTTP-EQUIV='Refresh' CONTENT='1; URL=Inventory.php'></p>";

}else{

 

$get=mysql_fetch_object(mysql_query("SELECT * FROM inventory WHERE username='$username' AND id=$id'"));

 

mysql_query("UPDATE users SET house='$get->name' WHERE username='$username'");

echo"You are now using $get->name as your house.";

}}

 

 

The MySQL bit is right, it's just that the page refreshes and makes no difference at all. I hope I am making sense. Anyway, the selecting code:

 

<a href='?use&id=$fucker->id'>Live in</a></td>

 

When I click on tht link ^^ it just refreshes, i guess it's with the PHP coding, can anyone help me?

Link to comment
https://forums.phpfreaks.com/topic/122907-wont-update-just-refreshes/
Share on other sites

instead of throwing your sql into mysql_query(), i would set it as a string so you can echo it to see if it's what you expect. also add error checking:

 

$sql = "UPDATE users SET house='$get->name' WHERE username='$username'";
echo "sql: $sql<br>";
mysql_query($sql) or die(mysql_error());

 

also, there appears to be a missing value for use in the URL:

<a href='?use&id=$fucker->id'>

 

use has no = sign

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.