Page 1 of 1

[SOLVED] Why can't I pull data out of my query?

Posted: Wed Jan 05, 2005 1:15 am
by Seona
Hi guys,

I have the following code:

Code: Select all

<?php
		/* declare some relevant variables  */
		$DBhost = "localhost";
		$DBuser = "username";
		$DBpass = "password";
		$DBName = "myDB";
		$table = "category";
		/* connect to database */
		$link = mysql_connect($DBhost,$DBuser,$DBpass);
		@mysql_select_db("$DBName") or die("Unable to select database $DBName"); 
		/* create the query to compare the form data with the user table */
		$sqlquery = "SELECT * FROM $table WHERE ID = $ID";
		/* run the query and check it worked */
		$result = mysql_query($sqlquery,$link);
		if (!$result = mysql_query($sqlquery,$link))
			exit("Illegal query");
		/* get the number of rows returned by the query */
		$number = mysql_num_rows($result);
		
		print "this is " . $row["CategoryName"] . "<br>";
		print "this is " . $row["ImageLocation"];
?>
The problem I have is that those last two rows there aren't returning anything. I get the absolute text, but no database data.

What have I done wrong? Almost the exact same code has worked on other pages. :(

Posted: Wed Jan 05, 2005 1:24 am
by feyd
forgot to fetch the row. ;)

Posted: Wed Jan 05, 2005 1:32 am
by Seona
:oops: Oh yeah... I knew that... really...

Thanks. :)