Jump to content


another error i cant sort out


1 reply to this topic

#1 Deathskin

    Young Padawan

  • Members
  • Pip
  • 70 posts
  • Gender:Male

Posted 26 January 2007 - 12:33 AM

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\display.php on line 10

<?php
//connect to mysql database
require ($_SERVER["DOCUMENT_ROOT"]."/Config/music.php");
$connection = mysql_connect($db_host, $db_user, $db_pw) or die(mysql_error());
mysql_select_db($db_name, $connection);

$sql = "SELECT * FROM songs";


while ($songs = mysql_fetch_array($sql)){
$ID = $songs[id];
$ARTIST = $songs[artist];
}
echo "$ID, $ARTIST";

?>

#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 26 January 2007 - 01:10 AM

$sql = "SELECT * FROM songs";

while ($songs = mysql_fetch_array($sql)){
$sql = string... as in not a resource. You forgot to call the mysql_query() function.
$sql = mysql_query("SELECT * FROM songs") or die(mysql_error());

while ($songs = mysql_fetch_array($sql)){






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users