escape_data() problems!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
WillUK
Forum Newbie
Posts: 24
Joined: Fri Nov 21, 2008 11:08 am

escape_data() problems!

Post 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
mmj
Forum Contributor
Posts: 118
Joined: Fri Oct 31, 2008 4:00 pm

Re: escape_data() problems!

Post by mmj »

You're missing a semicolon at the end of line 12, after the require satement. :)
WillUK
Forum Newbie
Posts: 24
Joined: Fri Nov 21, 2008 11:08 am

Re: escape_data() problems!

Post by WillUK »

Sorry for the delay in replying mmj - but thank you! Don't know how I missed that!
Post Reply