I am trying to fetch the values of a table which consists of three records or both x and y and the error message displayed is : mysql_query() expects parameter 1 to be string, resource given in C:\Program Files (x86)\EasyPHP-5.3.9\www\ag_fetching.php on line 17 Invalid query: please help me to figure out the problem. My code goes like this
<?php
$servername = "localhost";
$username = "root";
$password = "";
$conn =mysql_connect($servername, $username, $password);
if (! $conn) {
die("Connection failed: " . mysql_error());
}
mysql_select_db("PRJ") or die(mysql_error());
$result =mysql_query("SELECT * FROM CF");
if (!$result) {
die('Invalid query: ' . mysql_error());
}
$retval = mysql_query($result,$conn);
if (!$retval) {
die('Invalid query: ' . mysql_error());
}
$count=0;
while($row = mysql_fetch_array($retval)) {
$X[]=$row['x'];
$Y[]=$row['y'];
$count++;
}
mysql_close($conn);
?>