Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
187skillz
Forum Commoner
Posts: 39 Joined: Sun Aug 10, 2003 8:35 pm
Location: London
Post
by 187skillz » Sat Dec 10, 2005 10:32 pm
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.
Last edited by
187skillz on Sun Dec 11, 2005 10:08 am, edited 2 times in total.
Ambush Commander
DevNet Master
Posts: 3698 Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US
Post
by Ambush Commander » Sat Dec 10, 2005 10:59 pm
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.
187skillz
Forum Commoner
Posts: 39 Joined: Sun Aug 10, 2003 8:35 pm
Location: London
Post
by 187skillz » Sat Dec 10, 2005 11:31 pm
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.
187skillz
Forum Commoner
Posts: 39 Joined: Sun Aug 10, 2003 8:35 pm
Location: London
Post
by 187skillz » Sat Dec 10, 2005 11:59 pm
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
Last edited by
187skillz on Sun Dec 11, 2005 8:30 am, edited 1 time in total.
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Sun Dec 11, 2005 1:42 am
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
187skillz
Forum Commoner
Posts: 39 Joined: Sun Aug 10, 2003 8:35 pm
Location: London
Post
by 187skillz » Sun Dec 11, 2005 8:25 am
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