Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/142727-solved-simple-php-error/
Share on other sites

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!!

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 :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.