help accessing mysql database using php?

  • Thread starter Thread starter Yiaggi
  • Start date Start date
Y

Yiaggi

Guest
Hi guys,

I am a web designer trying to broaden my horizons by learning PHP & mySQL.

I have been learning mySQL for a few months now by following tutorials etc and have got quite a good understanding of the format now.

I have got onto adding a mySQL database to my website using PHP (I am still at the starting stages of learning PHP).

Basically - I have a small pretend database on mySQL called "phpdb" containing one table called "usertable".

I have connected to the database & tried to ask my first simple statement using:

<?php
mysql_connect ("localhost", "myusername", "mypassword");
mysql_connect_db ("phpdb")
$result = mysql_query ("select * from usertable");
print "$result"

-----------------------------------------

When I update my server I get a message that say "QUERY WAS EMPTY".

If I was to enter that simple "select * from usertable" on the mysql prompt I get the desired result - a table with 5 id's, first & last names & age.

What is it that I am doing wrong?

I am building up to doing guestbooks and message boards but need to get over this little stumbling block!

Any help would be greatly appreciated but especially any help that explains rather than directing me to tutorials that I have often already exhausted!

Another question I have for anyone man enough ....! In the same tutorial I was told to add a php code saying:

$numrows = mysql_num_rows ($result),

whenever i try to use this code I get an ugly syntax error! any idea's why?!

Ta in advance :)
 
Back
Top