Hey guys,
Going completely out of my mind. Still quite new to this(learning from peachpit press books) got to a point, I thought I was understanding. Beginning to learn to use the msql_real_escape_string() but after defining my function I get an error message telling me im calling an undefined function the script is below. If anyone can help Id be much appreciated.
Here is the error message I get:
Fatal error: Call to undefined function: mysql_real_escape_string() in c:phpdev5wwwpublicveezkaffregister.php on line 15
<?php
$page_title = ‘Register’;
include (‘header.inc’);
if (isset($_POST[‘submit’])) { //handle the form
require_once (‘mysql_connect.php’); //open the database
//create escape_data function
function escape_data ($data) {
global $dbc;
if (ini_get(‘magic_quotes_gpc’)) {
$data = stripslashes($data);
}
return mysql_real_escape_string($data, $dbc);
}
//end of function
$message = NULL; //creating an empty variable
//check for a first name
if (empty($_POST[‘first_name’])) {
$fn = FALSE;
$message .= ‘<p>You did not enter your First Name!</p>.’;
} else {
$fn = escape_data($
}
//check for a last name
if (empty($_POST[‘last_name’])) {
$ln = FALSE;
$message .= ‘<p>You did not enter your Last Name!</p>.’;
} else {
$ln = escape_data($
}
//check for an email address
if (empty($_POST[’email’])) {
$email = FALSE;
$message .= ‘<p>You did not enter your email address.</p>’;
} else {
$e = escape_data($
}
//check for a username
if (empty($_POST[‘username’])) {
$u = FALSE;
$message .= ‘<p>You did not enter a Username.</p>’;
} else {
$u = escape_data($
}
//check for a password and match against the confirmed password
if (empty($_POST[‘password1’])) {
$p = FALSE;
$message .= ‘<p>You did not enter a password</p>.’;
} else {
if ($_POST[‘password2’]) {
$p = escape_data($
} else {
$p = FALSE;
$message .= ‘<p>Your password did not match the confirmed password.</p>’;
}
}
if ($fn && $ln && $e && $u && $p) { //if everything is ok then…
//make the query
$query = “INSERT INTO users (username, first_name, last_name, email, password, registration_date)
VALUES (‘$u’, ‘$fn’, ‘$ln’, ‘$e’, PASSWORD(‘$p’), NOW() )”;
$result = @mysql_query ($query);// Run the query
if ($result) {
echo ‘<p><b>You have been registered!</b></p>’;
include (‘footer.inc’);//include footer
exit();///ext script
} else { //if registration did not work
$message .= ‘<p>Registration incomplete. This could be due to a system error. We apologise for any inconvenience.</p>’ . mysql_error() . ‘</p>’;
}
mysql_close(); //close the databse connection
} else {
$message .= ‘<p>Please try again</p>’;
}
}//end of main conditional
// print any error messages
if (isset($message)) {
echo ‘<font color=”red”>’, $message, ‘</font>’;
}
?>
<?php
include (‘footer.inc’);
?>
any help
Thanks
Bryndog ?