Database Not Selected
The error is "No database selected". However, there is nothing wrong with the name because the database "forms" exists. When I use the "test" database on phpMyAdmin, it works fine but it doesn't work on an identical database of a different name. I say it is identical because I copied the database in phpyMyAdmin so I could be mistaken.
Here is my code:
$con = mysql_connect("localhost");
die('Could not connect: ' . mysql_error());
$sql="INSERT INTO form_results (Name, Email, Subject, Message)
die('Error: ' . mysql_error());
echo "<p>Your record has been successfully added to the database.</p>";
you would need username and password...and whats about using the short method
plus do sanitize those get. Googling 'sql injection' might help.
My personal suggestion dont try to start learning php as poetry rather first read other how they write it,that would help.(just a suggestion)
Password in plain text
Thanks that worked but I don't want to put the password in plain text inside the document. I think that's quite insecure and I wouldn't think that is normal behaviour.
Originally Posted by frank1
This is actually common practice. You're not supposed to have files such as these in the document root where they can be read by users. if your document root is /var/www/mysite/public, then you would want any php files with sensitive data stored somewhere such as /var/www/mysite/lib.
Originally Posted by goodthenks