Jump to content

Recommended Posts

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>';
?>

Link to comment
https://forums.phpfreaks.com/topic/248921-mysql_clean-help-plz/
Share on other sites

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.

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.

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.

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']);

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.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.