AsiaUnderworld Posted July 21, 2008 Share Posted July 21, 2008 I've got a script in which when a user clicks a link it should update the status of that item, depending ond some variables however when they click it, it inserts "resource id 15" into the username row, rather then the username of the logged in person. heres the code. <?php if($city == "New York") { $id = 1; $id1 = 2; } if($city == "Chicago") { $id = 3; $id1 = 4; } if($city == "Las Vegas") { $id = 5; $id1 = 6; } $sql = "SELECT * FROM airport WHERE id='$id' OR id='$id1'"; $result = mysql_query($sql); $i = 0; while($i <= 1) { $row= mysql_fetch_assoc($result); $mins = $row['traveltime']; $arrival = date("H:i:s", strtotime("+".$mins." mins")); echo "<tr><td> </td><td><a onClick='showfly()' href='?flyto=".$row['ID']."'>".$row['city']." to ".$row['destination']."</a></td><td> </td></tr>"; echo "<tr><td> </td><td>$".$row['price']."</td><td> </td></tr><tr><td> </td><td> Next Flight At:".$arrival."</td><td> </td></tr>"; $i++; } $sql = "SELECT * FROM users WHERE ID = '{$userid}'"; $result = mysql_query($sql); $fetch = mysql_fetch_assoc($result); if($fetch['location'] == 1) { $city = "New York"; } if($fetch['location'] == 2) { $city = "Chicago"; } if($fetch['location'] == 3) { $city = "Las Vegas"; } $sql = "SELECT * FROM airportown WHERE city='$city'"; $result = mysql_query($sql); { $row= mysql_fetch_assoc($result); if(strlen($row['owner']) == 0) { $owner = "<a href='airport.php?buyairport=".$row['ID']."'>Pick Up</a>"; $sql1 = mysql_query("SELECT * FROM users WHERE Username = '{$uname}'"); $query = mysql_query($sql1); $rows = mysql_fetch_array($query); $uname = $rows['ID']; $username = mysql_query("SELECT * FROM users WHERE Username = '{$uname}'"); $sql = "SELECT * FROM users WHERE ID = '{$userid}'"; $result = mysql_query($sql); $fetch = mysql_fetch_assoc($result); if($fetch['location'] == 1) { $city = "New York"; } if($fetch['location'] == 2) { $city = "Chicago"; } if($fetch['location'] == 3) { $city = "Las Vegas"; } mysql_query("UPDATE airportown SET owner = '$username' WHERE city ='$city'"); } else { $owner = $row['owner']; $sql = "SELECT * FROM users WHERE Username = '{$owner}'"; $result = mysql_query($sql); $fetch = mysql_fetch_assoc($result); $sql = mysql_query("SELECT * FROM airportown WHERE city = '$city'"); $row = mysql_fetch_assoc($sql); $owner = "<a href='member.php?id=".$fetch['ID']."'>".$owner."</a>"; } echo $city." Airport is owned by ".$owner; } ?> Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted July 21, 2008 Share Posted July 21, 2008 You are doing <?php $username = mysql_query("SELECT * FROM users WHERE Username = '{$uname}'"); ?> then <?php mysql_query("UPDATE airportown SET owner = '$username' WHERE city ='$city'"); ?> you probably want to use the variable $uname not $username Ken Quote Link to comment 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.