Ang Posted September 8, 2007 Share Posted September 8, 2007 I'm very new to php and SQL (version 5.0.27). Can someone please advise on my connection problem. Message received is 'Unable to connect to SQL server". Thank you <html> <body> <HEAD> <link rel="stylesheet" type="text/css" href="style_sheet.css" /> </HEAD> <form action="EmployerDetails.php" method="post"> Thank you <?php echo $_POST["name"]; ?> and welcome..<br /> You're details have been added to our database.<br/> <?php include("$ mysql -u 112489 -h mysql.ict.school.edu.au -p 112489db "); $query = "INSERT INTO users "; $query .= "(user_id, name, address "; $query .= " values(0000,'$name','$address')"; mysql_pconnect("$ mysql -u 112489 -h mysql.ict.school.edu.au -p 112489db") or die("Unable to connect to SQL server"); mysql_select_db("tator_awtrey") or die("Unable to select database"); mysql_query($query) or die("Insert Failed!"); // Show the entries in the database function showEntries() { if (!($connection = @ mysql_connect("mysql -u 112489 -h mysql.ict.school.edu.au -p 112489db/users.inc", USER, PASSWORD))) die("Could not connect"); if (!(mysql_select_db(DATABASE, $connection))) showerror(); $query = "select name, address from users order by user_id"; if (!($result = @ mysql_query($query, $connection))) showerror(); while ($row = mysql_fetch_row($result)) { echo "<p>\n" . $row[0] . "\n"; echo "<p>\n -- <a href=\"mailto:" . $row[1] . "\">" . $row[2] . "</a>\n"; } if (!(mysql_close($connection))) showerror(); } // Add a new entry to the database function addEntry($name, $address) { if (!($connection = @ mysql_connect("localhost", USER, PASSWORD))) die("Could not connect"); if (!(mysql_select_db(DATABASE, $connection))) showerror(); $insert = "insert into users " . "values (null, \", \"$name\", \"$address\")"; if (!($result = @ mysql_query ($insert, $connection))) showerror(); if (!(mysql_close($connection))) showerror(); } */ ?> Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted September 8, 2007 Share Posted September 8, 2007 Umm, this is completely incorrect: mysql_pconnect("$ mysql -u 112489 -h mysql.ict.school.edu.au -p 112489db") mysql_pconnect requires three parameters hostname, username and password in that order. Not a command line. This is what the above line should be: mysql_pconnect("mysql.ict.school.edu.au", "112489", "112489db") Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.