The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

inserting into database

hi
im working on a personal project, i have apache,mysql and php all working fine on my machine, i can perform a select query through a web form but i cant seem to put anything into the database through a web form.

im thinking this has something to do with a password although i have set one up using the grant command in mysql

anyways here some of the code

@ $db = mysql_pconnect("localhost","bookorama","bookorama123");

if (!$db)
{
echo "Error: Could not connect to database. Please try again later.";
exit;
}

by the way this is all being done using windows98 and im starting mysql by navigating through explorer and clicking on the file but i never get asked for any passwords ! am i starting it the right way ?

im trying right now!

Im trying all your sugestions but i cant get past not recieving the first error msg unless i remove the user name and password then it accepts my details but doesnt enter them so im thinking it must be to do with these.

I totally missed that part, because my first advise would have been to remove your database username and password. I know you are running the script on localhost, but it is always best to leave those out when posting code on the forums, they have absolutely nothing to do with the working of the script.

Now, for the connection command, why not try this one:

PHP Code:

$dbx = mysql_connect();
mysql_select_db('books', $dbx;

Your problem was you used mysql_pconnect. I never used that string of command before, but I assume it is used to tell MySQL you are connecting with username and password -- as in mysql-passwordconnect.

Because you removed your username and password, this command could not have worked. When testing on localhost I always leave out usernames and passwords.

Originally posted by Mark T.Your problem was you used mysql_pconnect. I never used that string of command before, but I assume it is used to tell MySQL you are connecting with username and password -- as in mysql-passwordconnect.

Because you removed your username and password, this command could not have worked. When testing on localhost I always leave out usernames and passwords.

that's simply because, by default, MySQL isn't very secure and lets you connect anonymously. try not entering a username/password on my system = no workie.

- Matt ** Ignore old signature for now... **
Dr.BB - Highly optimized to be 2-3x faster than the "Big 3." "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR