-3
require("./connect.php");
$getid = $_GET['id'];
$getusername = mysql_query("SELECT username FROM user WHERE id='$getid'");
$getdesc = mysql_query("SELECT description FROM user WHERE id='$getid'");
echo "$getusername $getdesc";

I am having trouble, it is not echoing the data from those variables. I is returning resource id #10 and #11.

  • 3
    It is clear you are not experienced in PHP mysql database interactions. Stop using `mysql_*` statements and use something more secure like PDO or `mysqli_*`. – Locke Jun 23 '14 at 00:56

2 Answers2

1

You need to fetch the data first before you can use the mysql_query result...

please see the example in the PHP Documentation https://php.net/manual/en/function.mysql-fetch-row.php

<?php
$result = mysql_query("SELECT id,email FROM people WHERE id = '42'");
if (!$result) {
    echo 'Could not run query: ' . mysql_error();
    exit;
}
$row = mysql_fetch_row($result);

echo $row[0]; // 42
echo $row[1]; // the email value
?>
zho
  • 643
  • 1
  • 12
  • 27
0

Warning:

This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used.

pdo : https://php.net/manual/en/book.pdo.php

mysqli : http://www.php.net//manual/en/book.mysqli.php

You are trying to print out the resource ID of the query you just ran. To get to the actual results you have to specifically request it.

mysql_fetch_assoc($getusername); //should be used! 
Siv
  • 1,026
  • 19
  • 29