Database connection

Hi everyone,
I was wondering if someone could have a look at my codes here attached and tell me where I’m getting wrong.
I’m just trying to get clients leaving me their contacts details from my site which then will be posted in my MYSQL database. When the form is submitted I keep getting an error message.
Cheers,
Lamzo

<html>
<head>
<title>Registration</title>
</head>

<body>
<h1>Registration</h1>

<form action=“results.php” method=“post”>
<table border=“0”>
<tr>
<td>First Name</td>
<td><input type=“text” name=“fname” maxlength=“20” size=“50”></td>
</tr>
<tr>
<td>Last Name</td>
<td> <input type=“text” name=“lname” maxlength=“30” size=“50”></td>
</tr>
<tr>
<td>email</td>
<td> <input type=“text” name=“email” maxlength=“60” size=“50”></td>
</tr>
<tr>
<td colspan=“2”><input type=“submit” value=“Register”></td>
</tr>
</table>
</form>
</body>
</html>

<html>
<head>
<title>Registration Results</title>
</head>
<body>
<h1>Registration Results</h1>
<?php
// create short variable names
$fname=$_POST[‘fname’];
$lname=$_POST[‘lname’];
$email=$_POST[‘email’];

if (!$fname || !$lname || !$email) {
echo “You have not entered all the required details.<br />”
.“Please go back and try again.”;
exit;
}

if (!get_magic_quotes_gpc()) {
$fname = addslashes($fname);
$lname = addslashes($lname);
$email = addslashes($email);
}

@ $db = new mysqli(‘localhost’, ‘db_username’, ‘db_pwd’, ‘db_name’);

if (mysqli_connect_errno()) {
echo “Error: Could not connect to database. Please try again later.”;
exit;
}

$query = “insert into clients values
('”.$fname.“', '”.$lname.“', '”.$email.“')”;
$result = $db->query($query);

if ($result) {
echo $db->affected_rows." book inserted into database.";
} else {
echo “An error has occurred. The item was not added.”;
}

$db->close();
?>
</body>
</html>

Basically what I’ve done is, I’ve dropped that db and used a different template which works. Hence I haven’t really fixed the problem, thank you for assistance.
Lamzo

Glad you managed to fix it.

It is always a good idea to say how you managed the fix for those that may read this thread in the future.

Regards

Colin

Thank Colin, I’ve managed to fix it.

Regards,
Lamzo

Object not found!
The requested URL was not found on this server. The link on the[FONT=&quot]referring page[/FONT][COLOR=black][FONT=&quot]seems to be wrong or outdated. Please inform the author of[/FONT][/COLOR][URL=“http://localhost/test2/newbooks.html”][FONT=&quot]that page[/FONT]about the error.
If you think this is a server error, please contact the[FONT=Calibri][COLOR=#0000cc][FONT=&quot]webmaster

[COLOR=Black]The hyperlink on the referring page given in the error not found page contained in your uploaded files contains the URL.

Make sure your target file path is correct.

Regards

Colin
[/COLOR] [/FONT][/COLOR][/FONT]

Thanks Colin for replying to my thread, I’ve looked at the “localhost/test/newbooks.html” as you mention but I’d not see it in my codes, could you tell me how you found it?
I’ve started recently on PHP and it’s been doing my head in since then, so pls bear with me!

Cheers,
Lamzo

Hi Lamzo

Your error page is using localhost/test/newbooks.html as the referrer but this file is not included in your upload. Is your result page also in the test directory?

I think you may have a simple path problem here.

Regards

Colin

Cheers Anthony, I will repost it. This is my first posting!

It maybe a little while for the attachment to be approved (if at all).

Feel free to post the code here in the correct BB tags,

 et al.