Switching to "globals off"... need help
Posted: Tue Jul 29, 2003 12:06 am
Okay, so I've upgraded my PHP and now am preparing to run with "globals off"... however, as a newbie, I'm not sure I fully understand how to best change my scripts for getting form data into a mysql database... so, here's an example of a scritp that is called from an html form that I've reworked... and I'm wondering if there's a better/more effecient/easier way to deal with the change:
I've got several scripts that are all very similar, so I think if I can just get some direction with this little example, I should be set to rewrite the rest.
Thanks,
Scott
Code: Select all
<?PHP
$db = mysql_pconnect(localhost, root);
if (!$db) {
echo( "<p>Unable to connect to the " .
"database server at this time.</p>" );
exit();
}
//new code starts here
$Company=$_POSTї'Company'];
$Name=$_POSTї'Name'];
$Code=$_POSTї'Code'];
$Results=$_POSTї'Results'];
$Dept=$_POSTї'Dept'];
$Mailing=$_POSTї'Mailing'];
$Email=$_POSTї'Email'];
$Gender=$_POSTї'Gender'];
$Age=$_POSTї'Age'];
//new code ends here
mysql_select_db(dissertation, $db);
$sql = ("INSERT INTO participants (Company,Name,Code,Results,Dept,Mailing,Email,Gender,Age) VALUES ("$Company", "$Name", "$Code", "$Results", "$Dept", "$Mailing", "$Email", "$Gender", "$Age");");
$result = mysql_query($sql, $db);
?>
<html><body>
Done.</body></html>Thanks,
Scott