tmaiden Posted January 10, 2008 Share Posted January 10, 2008 Hello all, I've been playing around with this code; trying to get it to work; with little success. Any suggestions? config.php <?php function dbConnect() { $link = mysql_connect('...', '...', '...'); if (!$link) return false; return mysql_select_db('tmaiden'); } function getMovies() { $query = 'select * from movies'; $result = mysql_query($query); return $result; } ?> index.php <?php require_once('config.php'); if (!dbConnect()) { echo 'Error connecting to database'; exit; } $result = getMovies(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html> <head> ... </head> <body> ... <?php while($row = mysql_fetch_row($result)) { echo "<tr><td>" . $row['movie_id'] . "</td>"; echo "<td>" . $row['title'] . "</td>"; echo "<td>" . $row['ranking'] . "</td></tr>"; } ?> ... </body> </html> Any help would be greatly appricated! Quote Link to comment https://forums.phpfreaks.com/topic/85422-resolved-php-mysql-fetch-function/ Share on other sites More sharing options...
revraz Posted January 10, 2008 Share Posted January 10, 2008 My suggestion is to actually state what the problem is, so we at least know where to start looking. Hello all, I've been playing around with this code; trying to get it to work; with little success. Any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/85422-resolved-php-mysql-fetch-function/#findComment-435845 Share on other sites More sharing options...
rhodesa Posted January 10, 2008 Share Posted January 10, 2008 mysql_fetch_row() return a numerical array. you are probably looking for mysql_fetch_assoc() Quote Link to comment https://forums.phpfreaks.com/topic/85422-resolved-php-mysql-fetch-function/#findComment-435847 Share on other sites More sharing options...
tmaiden Posted January 10, 2008 Author Share Posted January 10, 2008 mysql_fetch_row() return a numerical array. you are probably looking for mysql_fetch_assoc() SWEET! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/85422-resolved-php-mysql-fetch-function/#findComment-435863 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.