Jump to content

Warning on page load


Hydrian

Recommended Posts

When i load my page. i get

 

Warning: mysql_fetch_array(): 9 is not a valid MySQL result resource in /home/a1761169/public_html/a40g/index.php on line 46

 

Here is my script

 

<?php

session_start();
error_reporting(-1);ini_set('display_errors', 1);
    $myServer = "";
    $myUser = "";
    $myPass = "";
    $myDB = "";
    //Connection to the database
    $dbhandle = mysql_connect($myServer, $myUser, $myPass)
    or die("Couldn't connect to SQL Server on $myServer");
    //Select a database to work with
    $selected = mysql_select_db($myDB, $dbhandle)
    or die("Couldn't open database $myDB");
$where = "";	
	if(isset($_GET['id'])){
	$id = $_GET['id'];
	$where = " WHERE id = $id";
}    



//Declare the SQL statement that will query the database
    $query = "SELECT * FROM `topics`$where";
    //Execute the SQL query and return records
    $result = mysql_query($query)
    or die('A error occured: ' . mysql_error());
    //Show result
    //Free result set memory
    mysql_free_result($result);
    //Close the connection 
    mysql_close($dbhandle);	
?>
<html>
<head>
</head>

<body>
	<br>
	<div style="background-color:#CCCCCC; color:#; border-radius:5px;" align=''>
		     <a href='create_topic.php'><b>New Topic<b></a>
	</div>
	<br><br>
	<?php

	while ( $record = mysql_fetch_array($result) )
	{	

	echo '<div id="content" >' . '<div style="background-color:#CCCCCC; color:#; border-radius:5px;">' . '<a href="index.php?id=' . $record["id"] . ' ">'. $record["topic_username"] .'</a>' . '       ' . '<a href="index.php?id=' . $record["id"] . ' ">'. $record["topic_name"] .'</a>' . '</div> ' . "<br>" . '<div style="word-wrap:break-word;div-layout:fixed; background-color:#CCCCCC; color:#; border-radius:5px;" width="500px" border="1">';
	if(isset($_GET['id'])){echo $record['topic_date']; echo "<br><br>"; echo $record['topic_input']; }
	else { echo ""; }
	echo '</div></div>';

	}

	?>
</body>
</html>

 

What have i done wrong?

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.