ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button
  Using MySQL from PHP
Subject:   Connect to MySQL DB
Date:   2006-05-09 17:00:30
From:   Cleo
I have a hosting account with GODADDY.com where I've been assigned a MySQL database. But I'm having trouble connecting to it. My code is as follows:

//Connect To Database
$yourfield = "F_Name";
$conn=mysql_connect($hostname,$username, $password) or die ('Error connecting to mysql');

# Check If Record Exists

$query = "SELECT * FROM $usertable";

$result = mysql_query($query);

while($row = mysql_fetch_array($result))
$name = $row["$yourfield"];
echo "Name: ".$name."

What's wrong please?

1 to 3 of 3
1 to 3 of 3