essjay_d12 Posted March 27, 2006 Share Posted March 27, 2006 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]thanksd Link to comment https://forums.phpfreaks.com/topic/5953-value-of-field-not-being-extracted-using-php-from-sql-query/ Share on other sites More sharing options...
obsidian Posted March 27, 2006 Share Posted March 27, 2006 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. Link to comment https://forums.phpfreaks.com/topic/5953-value-of-field-not-being-extracted-using-php-from-sql-query/#findComment-21308 Share on other sites More sharing options...
essjay_d12 Posted March 27, 2006 Author Share Posted March 27, 2006 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.Thanksd Link to comment https://forums.phpfreaks.com/topic/5953-value-of-field-not-being-extracted-using-php-from-sql-query/#findComment-21312 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.