MySQL connection problems using php
Posted: Mon Jun 02, 2008 4:26 am
Hi there, am a new member and i have some questions relating to php and mysql. I have designed a form to beused to aply for various courses offered in my college. when the users click the submit button the information is supposed to be sent to my local server in the registration Database created with mysql. I tried to test the connection to the database while at my local server using the following code but the computer does not display anything:
What is the problem with my code?
Is it Ok to test the connection to the database while at the host?
Why didn't i get an error message if it failed to connect or the confirmaton message after success?
Help me create a successful connection to the database please. The database name is StudReg and the table is feedback. I tested my php installation and it was fine.
thanks in advance
Code: Select all
<?php
$name="patric";
$hostname="localhost";
$pass=":depash";
$conn=mysql_connect($pass);
or die("Unable to connect to MySQL");
echo "Connected to MySQL";
//select a database to work with
$selected = mysql_select_db("StudReg",$conn)
or die("Could not select patric");
//execute the SQL query and return records
$result = mysql_query("SELECT * FROM feedback");
//fetch tha data from the database
while ($row = mysql_fetch_array($result))
{
echo "name:".$row{'name'}." comments:".$row{'comments'}.; //display the results
<br>
}
?>Is it Ok to test the connection to the database while at the host?
Why didn't i get an error message if it failed to connect or the confirmaton message after success?
Help me create a successful connection to the database please. The database name is StudReg and the table is feedback. I tested my php installation and it was fine.
thanks in advance