PHP help plz

Associate
Joined
28 Jan 2005
Posts
1,124
Hi all,

I'm getting this error:

Fatal error: Call to undefined function escape_data() in C:\wamp\www\registerfe.php on line 8


From this code:

<?php # Script 7.7 - register.php (3rd version after Scripts 7.3 & 7.5)

include ('./projectincludes/header.html');

require_once ('../mysql_connect.php'); // Connect to the db.


$t = escape_data($_POST['Title']); :mad: < Line 8
$s = escape_data($_POST['Surname']);
$f = escape_data($_POST['Forename']);
$i = escape_data($_POST['Initials']);



// Make query
$query = "INSERT INTO forensic_entomologist (Fe_ID, Title, Surname, Forename, Initials) VALUES (NULL, $t, $s, $f, $i)";

$result = @mysql_query ($query); // Run the query.

?>

<h2>Register Forensic Entomologist</h2>

<form action="registerfe.php" method="post">

<p>Title: <input type="text" name="Title" size="15" maxlength="10" value="<?php if (isset($_POST['Title'])) echo $_POST['Title']; ?>" /></p>
<p>Surname: <input type="text" name="Surname" size="20" maxlength="25" value="<?php if (isset($_POST['Surname'])) echo $_POST['Surname']; ?>" /></p>
<p>Forename: <input type="text" name="Forename" size="20" maxlength="25" value="<?php if (isset($_POST['Forename'])) echo $_POST['Forename']; ?>" /> </p>
<p>Initials: <input type="text" name="Initials" size="10" maxlength="5" value="<?php if (isset($_POST['Initials'])) echo $_POST['Initials']; ?>" /> </p>
<p><input type="submit" name="submit" value="Register" /></p><input type="hidden" name="submitted" value="TRUE" />
</form>

Any help would be great, i been stuck for hours.

Cheers,

Marty
 
Ok, i got it working... kind of.

It works with this code:

<?php # Script 7.7 - register.php (3rd version after Scripts 7.3 & 7.5)

include ('./projectincludes/header.html');

require_once ('../mysql_connect.php'); // Connect to the db.

if (isset($_POST['Title'])) {

$t = $_POST['Title'];
$s = $_POST['Surname'];
$f = $_POST['Forename'];
$i = $_POST['Initials'];

echo $t; :confused:

// Make query
$query = "INSERT INTO forensic_entomologist (Fe_ID, Title, Surname, Forename, Initials) VALUES (NULL, $t, $s, $f, $i)";

$result = @mysql_query ($query); // Run the query.

}
?>

<h2>Register Forensic Entomologist</h2>

<form action="registerfe.php" method="post">

<p>Title: <input type="text" name="Title" size="15" maxlength="10" value="" /></p>
<p>Surname: <input type="text" name="Surname" size="20" maxlength="25" value="" /></p>
<p>Forename: <input type="text" name="Forename" size="20" maxlength="25" value="" /> </p>
<p>Initials: <input type="text" name="Initials" size="10" maxlength="5" value="" /> </p>
<p><input type="submit" name="submit" value="Register" /></p><input type="hidden" name="submitted" value="TRUE" />
</form>

But when i remove the highlighed echo, nothing goes into the database!

How could an echo effect anyting??

Damn php :(

Marty
 
So confused!!

The first code i posted had loads of errors, the escape_dats function was me trying to copy a code snippet from a book and not knowing what it ment!

I deleted it and made alterations, and thats what i have posted for the second code. For some reason, it works fine when i have the echo in ( whole code works fine, data goes from form into database fine) but doesn't do anything when i take it out?!!!

Weird?

Marty
 
na, the records dont go into the database :(

For some reason, they are only going in then i enter numbers rather than letters! The database is setup as varchars for those fields going in.

echo is irrelivent now, i was just not consistant with my test data!

Ok, so:

It only works now if i enter data in ALL the fields and if all the fields contain numeric data!
 
Last edited:
Back
Top Bottom