List:MySQL on Win32« Previous MessageNext Message »
From:johnf Date:November 27 2004 12:54pm
Subject:PHP code query.
View as plain text  
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.

Thread
PHP code query.johnf27 Nov
  • Re: PHP code query.Janet Valade27 Nov
    • Re: PHP code query.Eve Atley27 Nov
    • Re: PHP code query.John Fitzsimons5 Dec
RE: PHP code query.R&D Australia John Bonnett29 Nov