inilz Posted April 18, 2013 Share Posted April 18, 2013 Hey guys, I'm trying to use the script to update a row based on what username is entered into a field. So far the page just keeps refreshing. I'm not sure what I'm doing wrong. Can anyone help me? Thanks <? //Connection Info $database = 'account_zf'; $database2 = 'cq'; $location = '192.168.1.500'; $username = 'Host'; $password = 'Pass'; $conn = mysql_connect("$location","$username","$password"); $conn1 = mysql_connect("$location","$username","$password"); //Start Code mysql_select_db($database,$conn) or die ("Could not open database"); //Select username ID from Account Table & Get Value if(isset($_POST['edit'])) { $sid = addslashes($_POST['id']); $maccid = mysql_query("SELECT `id` FROM `account` WHERE `name` = '$sid' LIMIT 1", $conn); $dmaccid = mysql_fetch_row($maccid); //Change DB to cq mysql_select_db($database2,$conn1) or die ("Could not open database"); $query = mysql_query("SELECT `recordmap_id` FROM `cq_user` WHERE `account_id` = '$maccid' LIMIT 1", $conn1); echo $dmaccid['id'] ; if(mysql_num_rows($query) > 0) { $row = mysql_fetch_assoc($query); if(in_array($row['recordmap_id'], $unallowed_maps)) { echo '<font color=black>You are on an unallowed map.</font><br>'; } else { mysql_query("UPDATE cq_user SET recordmap_id='1002', recordx='400', recordy='400' WHERE name='$maccid'", $conn1); echo '<font color=black>Your character has been successfully moved.</font><br>'; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/277092-page-just-refreshes/ Share on other sites More sharing options...
trq Posted April 18, 2013 Share Posted April 18, 2013 Why are you not using a join to do this? There is also nothing at all in that code that would refresh the page. We need more details about what exactly you are doing and what exactly is happening. Quote Link to comment https://forums.phpfreaks.com/topic/277092-page-just-refreshes/#findComment-1425528 Share on other sites More sharing options...
inilz Posted April 18, 2013 Author Share Posted April 18, 2013 On a page you enter your username, Query finds the primary key/id for your username in database account_zf Example: 50 Then on database cq, it looks for the recordmap_id for 50. If the the value for recordmap_id is any of the following. <?php $unallowed_maps = array(1038, 1845, 6000); ?> It will give you an error. else it will update the recordmap_id field to 1002. I never heard of a join. How does that work? Quote Link to comment https://forums.phpfreaks.com/topic/277092-page-just-refreshes/#findComment-1425531 Share on other sites More sharing options...
trq Posted April 18, 2013 Share Posted April 18, 2013 http://www.sitepoint.com/understanding-sql-joins-mysql-database/ Quote Link to comment https://forums.phpfreaks.com/topic/277092-page-just-refreshes/#findComment-1425536 Share on other sites More sharing options...
Solution inilz Posted April 23, 2013 Author Solution Share Posted April 23, 2013 Thanks. I managed to get it to work without joins. I just had stupid mistakes in the code. Quote Link to comment https://forums.phpfreaks.com/topic/277092-page-just-refreshes/#findComment-1426036 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.