Jump to content

[SOLVED] What does mysql_query(); Return?


jjacquay712

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/143661-solved-what-does-mysql_query-return/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.