Jump to content

Recommended Posts

I have run the query in MySQL and it returns 'THRILLER'

When i echo $genre in php is just blank

[code] $sql = "SELECT FAVOURITES FROM users WHERE USERNAME = '$_SESSION[username]'";
$check = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($check))
{
$genre = ($row['FAVOURITES']);
echo $genre;
}[/code]

thanks

d
try running a little troubleshooting within your code itself:

[code]
$sql = "SELECT FAVOURITES FROM users WHERE USERNAME = '$_SESSION[username]'";
$check = mysql_query($query) or die(mysql_error());
if (mysql_num_rows($check) > 0)
  while ($row = mysql_fetch_array($check))
  {
    $genre = $row['FAVOURITES'];
    echo $genre;
  }
else
  echo "No records returned for query:<br /><pre>$sql</pre>\n";
[/code]

this way, if you don't return any records, you can also make sure that your query is exactly what you think it is.
but i know that query returns a value 'Thriller' .. so the query is fine.

the username is unique so i was wondering if

[code]
while ($row = mysql_fetch_array($check))
{
$genre = ($row['FAVOURITES']);
[/code]

was the correct way to extract a query that i know only has one row one value.

Thanks

d
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.