$fetch=mysql_fetch_assoc(mysql_query("select * from users"));
Can we use these type of fetch statements?
Is this a proper way of using it?
I the following warning:
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given
$fetch=mysql_fetch_assoc(mysql_query("select * from users"));
Can we use these type of fetch statements?
Is this a proper way of using it?
I the following warning:
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given
Php is a multi-returnable language so that mysql_query return the array and the boolean (if query worked well or not). In this case youre pushing php to check boolean type but if you assign it before it will check either the ways. So go with;
$result = mysql_query("select * from users");
$fetch = mysql_fetch_assoc($result);
Yes, this will work!! But in case when there are multiple rows of record returned by the query, it will consider the first row only!
You can use mysql_query but it is a deprecated function check here
I suggest you to go with PDO or mysqli which is more advanced and Object oriented more malicious (sql injection) proof and easy to learn