Jump to content

php link error , resource id 15


AsiaUnderworld

Recommended Posts

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;

}

?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.