jjacquay712 Posted February 3, 2009 Share Posted February 3, 2009 I am a little confused about mysql querys in php. When you do a query like this: <?php $var = mysql_query("SELECT * FROM table;"); ?> What would the variable $var be / datatype? and how could i use mysql_fetch_array(); without the mysql_query() function inside of it? Quote Link to comment https://forums.phpfreaks.com/topic/143661-solved-what-does-mysql_query-return/ Share on other sites More sharing options...
jjacquay712 Posted February 3, 2009 Author Share Posted February 3, 2009 I found something about resources http://us3.php.net/manual/en/language.types.resource.php but im still confused ??? Quote Link to comment https://forums.phpfreaks.com/topic/143661-solved-what-does-mysql_query-return/#findComment-753760 Share on other sites More sharing options...
Maq Posted February 3, 2009 Share Posted February 3, 2009 Why don't you look in the manual? mysql_query() Usually it's the resource id or else false. Quote Link to comment https://forums.phpfreaks.com/topic/143661-solved-what-does-mysql_query-return/#findComment-753762 Share on other sites More sharing options...
printf Posted February 3, 2009 Share Posted February 3, 2009 a resource, on failure returns false... mysql_error () will be filled with the error (string) if it fails... Quote Link to comment https://forums.phpfreaks.com/topic/143661-solved-what-does-mysql_query-return/#findComment-753763 Share on other sites More sharing options...
premiso Posted February 3, 2009 Share Posted February 3, 2009 <?php $var = mysql_query("SELECT * FROM table;"); if (is_resource($var)) { while ($row = mysql_fetch_assoc($var)) { print_r($row); } }else { echo 'Query failed, error is: ' . mysql_error(); } ?> Hope that helps ya. Quote Link to comment https://forums.phpfreaks.com/topic/143661-solved-what-does-mysql_query-return/#findComment-753767 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.