Page 1 of 1

escape_data() problems!

Posted: Fri Nov 21, 2008 11:32 am
by WillUK
Hi, I am juststarting out as a developer, so apologies if my problem is just plain dumb!

I'm getting the error with respect to a function within a piece of code, that I am writing:
Parse error: syntax error, unexpected T_FUNCTION in C:\wamp\www\TrainingApplication\register.php on line 12

It is particularly confusing because I am copying it from a text book. It is one of the exercises in a Larry Ullman book (PHP and MySQL). I've checked the book and I'm 100% sure that I have copied it correctly....

Here is the code structure for the finction (I have made a comment where Line 12 is) :

$page_title = 'Register';
include ('templates/header.inc');

if (isset($_POST['submit'])) { //Handle the form.

require_once ('./mysql_connect.php') //Connect to the database.

//Create a function for escaping the data.
function escape_data ($data) { --------------THIS IS LINE 12 --------------

global $dbc; //Need the connection.
if (ini_get('magic_quotes_gpc')) {
$data = stripslashes($data);
}
return mysql_real_escape_string($data, $dbc);
} //End of function.


Please help. Am I missing something??

Cheers
Will

Re: escape_data() problems!

Posted: Fri Nov 21, 2008 11:38 am
by mmj
You're missing a semicolon at the end of line 12, after the require satement. :)

Re: escape_data() problems!

Posted: Tue Dec 02, 2008 5:27 pm
by WillUK
Sorry for the delay in replying mmj - but thank you! Don't know how I missed that!