You said the database and table had the same name but it seems the table
is "invcomma" and the database is "jf_invcomma". Also in the PHP you
quote I don't see where you actually executed the SQL statement you
created?
John Bonnett
-----Original Message-----
From: johnf@stripped [mailto:johnf@stripped]
Sent: Saturday, 27 November 2004 11:24 PM
To: win32@stripped
Subject: PHP code query.
Hi,
I try an SQL query in phpMyAdmin and it works okay. I am also given a
connection string in PHP as well. When I try to combine these into a
.PHP page to query the database it doesn't work. No error. Nothing.
I am obviously doing something wrong but I don't know what. My database
and table have the same name but I hope that doesn't matter. Apart from
changing my password/username below, this is what I tried ;
<html>
<body>
<?php
$dbh=mysql_connect ("localhost", "jf_USER", "password") or die ('I
cannot connect to the database because: ' . mysql_error());
mysql_select_db ("jf_invcomma");
$sql = 'SELECT '
. ' `invcomma`.`ISBN`,'
. ' `invcomma`.`TITLE`,'
. ' `invcomma`.`AUTHOR`,'
. ' `invcomma`.`PRICE`,'
. ' `invcomma`.`CAT`'
. ' FROM'
. ' `invcomma`'
. ' WHERE'
. ' `invcomma`.`AUTHOR` = "Hall Judy" '
. ' ORDER BY'
. ' `invcomma`.`ISBN`,'
. ' `invcomma`.`TITLE`,'
. ' `invcomma`.`AUTHOR`,'
. ' `invcomma`.`PRICE`,'
. ' `invcomma`.`CAT` LIMIT 0, 30';
?>
</body>
Can anyone tell me what I have done wrong and/or the correct code to
make things work please ?
Regards, John.