lokie538 Posted January 28, 2009 Share Posted January 28, 2009 Hi, Ive written a whole site with the latest php and mysql versions, but it seems the clients host doesnt have mysql 5. So im trying to rewrite the site to work with mysql 4. Are there any good tutorials around that work with this old version? Im trying to figure out how to just show data from a table, below is the code I have atm. <?php $host="localhost"; $user="awesomef_alluser"; $passwd ="999999"; $dbname = "awesomef_pic"; $cxn = mysql_connect($host,$user,$passwd,$dbname) or die ( "Location: error.html" ); mysql_select_db('awesomef_pic', $cxn); $result = mysql_query('SELECT * FROM images'); $num = mysql_numrows($result); \\ this is so i can make a while loop to show the data mysql_close(); I get this error: Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in is there a mysql_fetch_array($result) that will work with mysql 4? Quote Link to comment https://forums.phpfreaks.com/topic/142727-solved-simple-php-error/ Share on other sites More sharing options...
Philip Posted January 28, 2009 Share Posted January 28, 2009 Try: mysql_num_rows instead of mysql_numrows and $result = mysql_query('SELECT * FROM images') or die(mysql_error()); instead of $result = mysql_query('SELECT * FROM images'); Quote Link to comment https://forums.phpfreaks.com/topic/142727-solved-simple-php-error/#findComment-748183 Share on other sites More sharing options...
lokie538 Posted January 28, 2009 Author Share Posted January 28, 2009 Try: mysql_num_rows instead of mysql_numrows and $result = mysql_query('SELECT * FROM images') or die(mysql_error()); instead of $result = mysql_query('SELECT * FROM images'); Lol yea I forgot to do or die error GAAAHHHHHH Problem was the user didnt have permission to access the database!! mysql_select_db('awesomef_pic', $cxn) or die(mysql_error()); Works fine now thanks kingphilip!! Quote Link to comment https://forums.phpfreaks.com/topic/142727-solved-simple-php-error/#findComment-748188 Share on other sites More sharing options...
phpdragon Posted January 28, 2009 Share Posted January 28, 2009 could try $link = mysql_connect('localhost', 'awesomef_alluser', '999999'); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db('awesomef_pic', $link); $sql = "SELECT * FROM images"; $result = mysql_query($sql); while ($result_row = mysql_fetch_array($result)) { // list variables from database here pay attention to CASE of names of tables and columns $name = $result_row["name"]; echo $name . "<br/>"; } hope that helps Quote Link to comment https://forums.phpfreaks.com/topic/142727-solved-simple-php-error/#findComment-748192 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.