mysql - How do I store the results of an SQL call in a php array -


i have been trying create sign form website , keep struggling trying check if user's username had been used else signed website in past. using mysql database store information , trying access past usernames through using php. specific part of code keeps returning error.

$query = "select username users"; $records = mysql_query("select username users"); $result = mysql_query($records);  $result_array = array(); while($row = mysql_fetch_assoc($result)) {     $result_array[] = $row['username']; } 

the error messages receiving are:

  1. warning: mysql_query() expects parameter 1 string, resource given in ...
  2. warning: mysql_fetch_assoc() expects parameter 1 resource, null given in... thank much!

the problem doing mysql_query twice 1 on $records variable , on resultlike so:

$records = mysql_query("select username users"); $result = mysql_query($records); 

what need this:

$records = "select username users"; $result = mysql_query($records); 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -