Jump to content

mysql_fetch_array() error (line 15)


otester

Recommended Posts

I have two databases with different sets of code on the same page, first one doesn't work, second one does. There is no difference in the setup of either databases.

 

When blocking out this section, the area it should show up in is blank, but I can still access my website (error 500 inhibited this):

 

while($row = mysql_fetch_array($column1))
  		{
	echo $row['ColumnT1'];
  		}

 

First:

 

<?php
	$con = mysql_connect("x","x","x");
	if (!$con)
  		{
  		die('Could not connect: ' . mysql_error());
  		}

	mysql_select_db("x", $con);

	$column1 = mysql_query("SELECT * FROM Main");

	while($row = mysql_fetch_array($column1))
  		{
	echo $row['ColumnT1'];
  		}

	mysql_close($con);
	?>

 

Second:

 

<?php 
	$con = mysql_connect("x","x","x");
	if (!$con)
  		{
  		die('Could not connect: ' . mysql_error());
  		}

	mysql_select_db("x", $con);

	$comments = mysql_query("SELECT * FROM Comments
						  ORDER BY Date ASC");

	while($row = mysql_fetch_array($comments))
  		{
	echo "> ";	
		echo $row['Messages'];
  		echo "<br />";
  		}

	mysql_close($con);
	?>

 

 

Any ideas?

 

 

Thanks,

 

otester

Link to comment
Share on other sites

in the first section, please add this

 

 $column1 = mysql_query("SELECT * FROM Main") 
if ( !$column1 ) {

   die("error found: " .  mysql_error() );

}

 

 

please tell us the result

 

Result:

 

error found: No database selected

Link to comment
Share on other sites

Seems I made a boo boo, forgot to add user to database list in hosting panel, just did that, error no longer displayed.

 

Putting the original code back in results in it working.

 

 

Thanks for your help and quick reply!  :D

Link to comment
Share on other sites

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.