Davie33 Posted October 11, 2011 Share Posted October 11, 2011 Hi am trying to fix this code am working on with mysql_clean an am getting abit confused with it can help me out with it?. Am wanting the name of the topic to show here echo '<b>Topic - '.$blog['topic'].'</b>';. <?php $id = mysql_clean($_GET['id']); $query = mysql_query("SELECT * FROM `blog` WHERE id = '$id'") or die(mysql_error()); $blog = mysql_fetch_array($query) or die(mysql_error()); echo '<b>Topic - '.$blog['topic'].'</b>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/248921-mysql_clean-help-plz/ Share on other sites More sharing options...
Pikachu2000 Posted October 11, 2011 Share Posted October 11, 2011 There is no predefined mysql_clean() function in php, and your question isn't very clear. What exactly is the problem? Include any errors returned by the code in your reply, please. Quote Link to comment https://forums.phpfreaks.com/topic/248921-mysql_clean-help-plz/#findComment-1278361 Share on other sites More sharing options...
Davie33 Posted October 11, 2011 Author Share Posted October 11, 2011 Here is the error and ty for THE reply back Fatal error: Call to undefined function mysql_clean() in C:\wamp\www\mini-arcade-games\templates\arcade\home.php on line 7 line 7 is $id = mysql_clean($_GET['id']); Am trying to get the name of the topic to show If i make topic and say i named it php codes then this part echo '<b>Topic - '.$blog['topic'].'</b>'; will show the name of the topic. Quote Link to comment https://forums.phpfreaks.com/topic/248921-mysql_clean-help-plz/#findComment-1278369 Share on other sites More sharing options...
Pikachu2000 Posted October 11, 2011 Share Posted October 11, 2011 You're getting the error because there is supposed to be a user-defined function called mysql_clean() that needs to be included, but isn't. That's causing a fatal error and until you either include the function, find a way to do the same thing without it, or (and I really don't recommend this) don't use it at all, you'll have the same problem. Quote Link to comment https://forums.phpfreaks.com/topic/248921-mysql_clean-help-plz/#findComment-1278398 Share on other sites More sharing options...
jcbones Posted October 11, 2011 Share Posted October 11, 2011 Replace mysql_clean() with mysql_real_escape_string(). Quote Link to comment https://forums.phpfreaks.com/topic/248921-mysql_clean-help-plz/#findComment-1278412 Share on other sites More sharing options...
Davie33 Posted October 12, 2011 Author Share Posted October 12, 2011 Hi do u mean like this ? sry am still learning php. <?php $id = mysql_real_escape_string($_GET['id']); $query = mysql_query("SELECT * FROM `blog` WHERE id = '$id'") or die(mysql_error()); $blog = mysql_fetch_array($query) or die(mysql_error()); echo '<b>Topic - '.$blog['topic'].'</b>'; ?> I guess not if its not working :S. Quote Link to comment https://forums.phpfreaks.com/topic/248921-mysql_clean-help-plz/#findComment-1278611 Share on other sites More sharing options...
jcbones Posted October 13, 2011 Share Posted October 13, 2011 That is correct. What do you mean by "not working"? Quote Link to comment https://forums.phpfreaks.com/topic/248921-mysql_clean-help-plz/#findComment-1279166 Share on other sites More sharing options...
Davie33 Posted October 14, 2011 Author Share Posted October 14, 2011 Hi i havent a clue am just getting a blank page apart from me header showing . Quote Link to comment https://forums.phpfreaks.com/topic/248921-mysql_clean-help-plz/#findComment-1279503 Share on other sites More sharing options...
jcbones Posted October 15, 2011 Share Posted October 15, 2011 Post the full code. Quote Link to comment https://forums.phpfreaks.com/topic/248921-mysql_clean-help-plz/#findComment-1279531 Share on other sites More sharing options...
bspace Posted October 15, 2011 Share Posted October 15, 2011 mysql_real_escape_string() needs a connection to operate mostly it'll just use the last open connection and therefore things will look ok but if you haven't opened a connection then it won't operate if this is the problem - try this instead $search=array("\\","\0","\n","\r","\x1a","'",'"'); $replace=array("\\\\","\\0","\\n","\\r","\Z","\'",'\"'); $id = str_replace($search,$replace,$_GET['id']); Quote Link to comment https://forums.phpfreaks.com/topic/248921-mysql_clean-help-plz/#findComment-1279533 Share on other sites More sharing options...
jcbones Posted October 15, 2011 Share Posted October 15, 2011 If he hasn't opened a connection, then his query wouldn't work. So the fix is to open a connection. Quote Link to comment https://forums.phpfreaks.com/topic/248921-mysql_clean-help-plz/#findComment-1279604 Share on other sites More sharing options...
Davie33 Posted October 16, 2011 Author Share Posted October 16, 2011 bspace and jcbones thanks for the replys. I think i need to make what jcbones said so am trying to make another file so both files connect. Am trying to make a blog called face-twit and learning php. If anyone would like to join and help out with coding if u have free time then i would set up a forum for it. Quote Link to comment https://forums.phpfreaks.com/topic/248921-mysql_clean-help-plz/#findComment-1279796 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.