Bullet Posted September 5, 2008 Share Posted September 5, 2008 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 More sharing options...
Ken2k7 Posted September 5, 2008 Share Posted September 5, 2008 No, that's not PHP. To achieve what you want, you'll need to utilize AJAX. Link to comment https://forums.phpfreaks.com/topic/122907-wont-update-just-refreshes/#findComment-634797 Share on other sites More sharing options...
Bullet Posted September 5, 2008 Author Share Posted September 5, 2008 Why isn't it PHP? I've used exactly the same style in another document used for something else and it ahs worked. Link to comment https://forums.phpfreaks.com/topic/122907-wont-update-just-refreshes/#findComment-634807 Share on other sites More sharing options...
Ken2k7 Posted September 5, 2008 Share Posted September 5, 2008 Because with PHP alone, if you submit something with a submit button (most common) or a link in your situation, then it refreshes the page because you're going to that link. Link to comment https://forums.phpfreaks.com/topic/122907-wont-update-just-refreshes/#findComment-634811 Share on other sites More sharing options...
BlueSkyIS Posted September 5, 2008 Share Posted September 5, 2008 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 Link to comment https://forums.phpfreaks.com/topic/122907-wont-update-just-refreshes/#findComment-634812 Share on other sites More sharing options...
kenrbnsn Posted September 5, 2008 Share Posted September 5, 2008 No, a variable in a URL doesn't have to have a value. Ken Link to comment https://forums.phpfreaks.com/topic/122907-wont-update-just-refreshes/#findComment-634833 Share on other sites More sharing options...
Bullet Posted September 5, 2008 Author Share Posted September 5, 2008 Still makes no difference and it just refreshes. Link to comment https://forums.phpfreaks.com/topic/122907-wont-update-just-refreshes/#findComment-634838 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.