redarrow Posted September 21, 2009 Share Posted September 21, 2009 my example does not work lol, how do you create a funtion to protect database information.. and add it to any set varable to work? <?php function valadate($x){ $x=mysql_real_esape_string($_POST['$x']); return($x); } echo valadate($x="john"); ?> Link to comment https://forums.phpfreaks.com/topic/174947-solved-how-to-create-a-function-to-protect-database/ Share on other sites More sharing options...
ozestretch Posted September 21, 2009 Share Posted September 21, 2009 <?php function valadate($x){ $x=mysql_real_esape_string($_POST['$x']); // should this - $_POST['$x'] actually be $x !? return($x); } echo valadate($x="john"); ?> Link to comment https://forums.phpfreaks.com/topic/174947-solved-how-to-create-a-function-to-protect-database/#findComment-922010 Share on other sites More sharing options...
nankoweap Posted September 21, 2009 Share Posted September 21, 2009 mysql_real_esape_string is spelled incorrectly. it's mysql_real_escape_string. Link to comment https://forums.phpfreaks.com/topic/174947-solved-how-to-create-a-function-to-protect-database/#findComment-922014 Share on other sites More sharing options...
redarrow Posted September 21, 2009 Author Share Posted September 21, 2009 WORKS........ WHY DONT THIS WORK GOING GRAY LOL <?php //CREATE THE FUNCTION. function valadate($x){ $x=mysql_real_escape_string(strip_tags(htmlentities($x, ENT_QUOTES))); return($x); } // ADD A VARIABLE AS WHAT EVER. $redarrow=$_POST['redarrow']; // SET THE VARIABLE AS WHAT EVER $redarrow="redarrow"; //ADD THE FUNTION TO THE VARIABLE. $redarrow=valadate($x=$redarrow); //ECHO THE VARIABLE WITH ADDED FUNCTION. echo $redarrow; ?> Link to comment https://forums.phpfreaks.com/topic/174947-solved-how-to-create-a-function-to-protect-database/#findComment-922016 Share on other sites More sharing options...
nankoweap Posted September 21, 2009 Share Posted September 21, 2009 what errors are you getting? Link to comment https://forums.phpfreaks.com/topic/174947-solved-how-to-create-a-function-to-protect-database/#findComment-922019 Share on other sites More sharing options...
redarrow Posted September 21, 2009 Author Share Posted September 21, 2009 so sorry i had no database add to the page i got mysql error dar i am lol Link to comment https://forums.phpfreaks.com/topic/174947-solved-how-to-create-a-function-to-protect-database/#findComment-922022 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.