Page 1 of 1

Very Basic Help

Posted: Tue Feb 03, 2009 12:15 pm
by ukcop
Im learning, very slowly, and trying to put something VERY basic together, that won't seem to work.

I have written:

Code: Select all

<?php
 
$host="localhost" ;
$user="membershipsite" ;
$password="password" ;
$connection = mysql_connect($host,$user,$password)
    or die ("Couldn't connect to server.");
 
$db = mysql_select_db("membership",$connection)
    or die ("Couldn't select database.");
    
    
    $query= "SELECT * FROM client";
    $result= mysql_query($query)
        or die ("Couldn't execute query.");
    
    ?>
But it says Couldn't execute query. Is there something I have done wrong somewhere?

Thanks.

Re: Very Basic Help

Posted: Tue Feb 03, 2009 12:24 pm
by mickeyunderscore
It looks good to me. Is your table name definitely spelled correctly?

BTW are you running XAMPP?

To help diagnose the problem, you could change your die statement to:

Code: Select all

or die ("Couldn't execute query. " . mysql_error());

Re: Very Basic Help

Posted: Tue Feb 03, 2009 12:26 pm
by Skoalbasher
ukcop wrote:Im learning, very slowly, and trying to put something VERY basic together, that won't seem to work.

I have written:

Code: Select all

<?php
 
$host="localhost" ;
$user="membershipsite" ;
$password="password" ;
$connection = mysql_connect($host,$user,$password)
    or die ("Couldn't connect to server.");
 
$db = mysql_select_db("membership",$connection)
    or die ("Couldn't select database.");
    
    
    $query= "SELECT * FROM client";
    $result= mysql_query($query)
        or die ("Couldn't execute query.");
    
    ?>
But it says Couldn't execute query. Is there something I have done wrong somewhere?

Thanks.
Instead of making die("Couldn't execute")

try

Code: Select all

 
$result = mysql_query($query) or die(mysql_error());
 
Should tell you exactly what's wrong with the query.

Re: Very Basic Help

Posted: Tue Feb 03, 2009 1:02 pm
by ukcop
Thanks for the help! I did figure it out, it appears that the table being called Client with a capital C makes a big difference as I wrote it with a lowercase C.

Thanks again.