[solved]-Code Give Error Message Saying Host Known Q38997334
Why does this code give me an error message saying that the hostis not known?
<?php
// Confirmation page setup
//Create connection
$con = mysql_connect(‘ :mysql’, ‘test2’, ‘123’);//’mysql.default_host’, ‘mysql_user’, ‘mysql_password’
//check connection
if (!$con) {
die(“Connection failed: ” . mysql_error());
}
echo “Connected successfully.”;
// selected database
mysql_select_db(“CIT647StudentsConcertsProfiles”. $con);
//create random uniqe ID for rownum field in databasetable
$pattern = “1234567890”;
$rownum = $pattern{rand(0,10)};
for ($i = 1; $i < 10; $i++)
{
$rownum = $pattern{rand(0,10)};
}
// sql to create test table
$sql = “INSERT INTO CIT647StudentsConcertProfilesTable (rownum,firstname, lastname, telephone)
VALUES (‘$rownum’, ‘$_POST[firstname]’, ‘$_POST[lastname]’,$_POST[telephone])”;
//store from names in variables
$firstname = $_POST[‘firstname’];
$lastname = $_POST[‘lastname’];
$telephone = $_POST[‘telephone’];
if (myql_query($sql, $con)) {
echo “Records added successfully.”;
} else {
echo “ERROR: Not able to execute $sql. ” . mysql_error($con);
}
//close the connection
mysql_close($con);
?>
Expert Answer
Answer to Why does this code give me an error message saying that the host is not known? … . . .
OR

