Page 1 of 1

Pls take a look at this.

Posted: Sat Dec 10, 2005 10:32 pm
by 187skillz
I'm following a tutorial and I've entered everything into my database correctly but when I run the php in my browser I get this error

**********



Here's my line up to 12

Code: Select all

<?php

	// This page will list all of the items
	// from the items table. Each item will have
	// a link to add it to the cart

	include("db.php");
	
	// Get a connection to the database
	$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
	[b]$result = mysql_query("select * from items order by itemName asc");[/b]
	?>
11 is in bold.


My other error line 42 is in bold

Code: Select all

</tr>
	[b]<?php[/b]
                     while($row = mysql_fetch_array($result))
                   {
	   ?>
Any idea pls?


This is the tutorial I'm following.....

****


Thanks.

Posted: Sat Dec 10, 2005 10:59 pm
by Ambush Commander
Are you sure you're giving the right credentials? Also, is the database installed on your computer? Line 42's error comes from not having any MySQL database link to grab the data from.

Posted: Sat Dec 10, 2005 11:31 pm
by 187skillz
Thanks for your reply, nah it's installed on university's server and I read our uni's mysql documentation it says use

mysql.cms.xxx.xx.xx

For the db server.

Posted: Sat Dec 10, 2005 11:59 pm
by 187skillz
I tried it on my own website and still getting the line 42 error...take a look pls

***

Pls take a look at the files, there are only 3, db.php, cart.php and products.php, maybe you can spot the errors....at the bottom of this page.

***

Thanks

Posted: Sun Dec 11, 2005 1:42 am
by John Cartwright
change the instances of

Code: Select all

$result = mysql_query("select * from items order by itemName asc");
to include debugging code

Code: Select all

$result = mysql_query("select * from items order by itemName asc") or die(mysql_error());
for a more helpful clue as to why the query failed :wink:

Posted: Sun Dec 11, 2005 8:25 am
by 187skillz
I did and realised that it was my mistake when trying it on my website, I had forgotten to create a table item...now that's working as intended, thanks for the input