-5

I know this has been asked a million and one time but and I have read them, I can't seem to see what the problem is.


I'm using the select code from a w3 tutorial:

$con = mysql_connect("$server","#user","$admin");

if (!$con) {
  die('Could not connect: ' . mysql_error());
}

mysql_select_db("$db", $con);

$result = mysql_query("SELECT * FROM options");

while($row = mysql_fetch_array($result)) {
  echo $row['copy_right'];
}

mysql_close($con);


And then is displayed in:

<?php $FP->copy_right(); ?> if it matters, 


The full error I get is:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/frontcms/app/core/core.php on line 112

Zuul
  • 15,997
  • 6
  • 59
  • 87
Denver
  • 1
  • 3

3 Answers3

1

"#user" sound like to be $user.

Add the error check will help you know what is wrong.

if (!$result) {
  die(mysql_error());
}

And note: Don't quote your variables.

$con = mysql_connect("$server","#user","$admin");

should just be

$con = mysql_connect($server, $user, $admin);

and

mysql_select_db("$db", $con);

should just be:

mysql_select_db($db, $con);
xdazz
  • 154,648
  • 35
  • 237
  • 264
0

try this,

while ($row = mysql_fetch_array($result, MYSQL_ASSOC))

See PHP Manual: mysql_fetch_array

John Woo
  • 249,283
  • 65
  • 481
  • 481
0

i guess you have a typo error:

$con = mysql_connect("$server","#user","$admin");

#user should be $user

sephoy08
  • 1,076
  • 7
  • 16