Jump to content

Recommended Posts

I have this code for dislpay information (by the id of the user) was stored in the database but it give an error and I think it from this line    $id = $_GET['id'];

$query  = "SELECT * FROM $table WHERE id='$id'LIMIT 1";

And this my code:

]<html>
<head>
<title>Title here!</title>
</head>
<body>

<?php

$host      = "localhost";
$user      = "";
$password  = "";

$db        = "Job seeker";
$table     = "personalinformation";

mysql_connect($host,$user,$password) or die("Failed to connect");
     mysql_select_db($db) or die("Falied to select database");
      $id = $_GET['id'];
      $query  = "SELECT * FROM $table WHERE id='$id'LIMIT 1";

       //$query = "SELECT * FROM $table WHERE id='$id' LIMIT 1";
       $result = mysql_query($query) or die("problem with query: ".$query);
       $row = mysql_fetch_array($result);


     if ($row){



              // echo "<td><td><tr>$myrow[id]</tr><tr>$myrow[Address]</tr><tr>$myrow[City]</tr><tr>$myrow[Fax]</tr><tr>$myrow[specialization]</tr><tr>$myrow[TargetSalary]</tr><tr>$myrow[JobType]</tr><tr>$myrow[WillingToRelocate]</tr></td></td>"  ;

      }

       else  {
         echo "mysql Error: " . mysql_error();
     }
?>

<h3> Personal Information form</h3>
     <table border=1>
     <tr>
	<td>id</td>
        <td><?=$row['id'];?></td>
</tr>
<tr>
	<td>Address</td>
	<td><?=$row['Address'];?></td>
</tr>
<tr>
	<td>City</td>
	<td><?=$row['City'];?></td>
</tr>
<tr>
	<td>Fax</td>
	<td><?=$row['Fax'];?> </td>
</tr>
<tr>
	<td>Specialization</td>
	<td><?=$row['Specialization'];?></td>
</tr>
<tr>
	<td>TargetSalary</td>
	<td><?=$row['TargetSalary'];?></td>
</tr>
<tr>
	<td>JobType</td>
	<td><?=$row['JobType'];?></td>
  </tr>
  <tr>
	<td>WillingToRelocate</td>
	<td><?=$row['WillingToRelocate'];?> </td>
  </tr>   </table>




</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/53442-mysql-error/
Share on other sites

Chnage this:

query  = "SELECT * FROM $table WHERE id='$id'LIMIT 1";

       //$query = "SELECT * FROM $table WHERE id='$id' LIMIT 1";
       $result = mysql_query($query) or die("problem with query: ".$query);
       $row = mysql_fetch_array($result);


     if ($row){



              // echo "<td><td><tr>$myrow[id]</tr><tr>$myrow[Address]</tr><tr>$myrow[City]</tr><tr>$myrow[Fax]</tr><tr>$myrow[specialization]</tr><tr>$myrow[TargetSalary]</tr><tr>$myrow[JobType]</tr><tr>$myrow[WillingToRelocate]</tr></td></td>"  ;

      }

       else  {
         echo "mysql Error: " . mysql_error();
     }

to this:

$query  = "SELECT * FROM $table WHERE id='$id'LIMIT 1";

//$query = "SELECT * FROM $table WHERE id='$id' LIMIT 1";
$result = mysql_query($query) or die('problem with query: ' . $query . '<br />' . mysql_error());

if(mysql_num_rows($result) == 1)
{
    $row = mysql_fetch_array($result);

    echo "\n<tr>
  <td>{$myrow['id']}</td>
  <td>{$myrow['Address']}</td>
  <td>{$myrow['City']}</td>
  <td>{$myrow['Fax']}</td>
  <td>{$myrow['Specialization']}</td>
  <td>{$myrow['TargetSalary']}</td>
  <td>{$myrow['JobType']}</td>
  <td>{$myrow['WillingToRelocate']}</td>
</tr>\n";
}
else
{
    echo 'No results returned';
}

Link to comment
https://forums.phpfreaks.com/topic/53442-mysql-error/#findComment-264225
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.