PDA

View Full Version : Database information not displaying properly


destrugter
03-30-2008, 08:05 AM
Ok, this has to do with some code i received help on...its listed below.

<?php
$con = mysql_connect("mysql","cheese","pizza");

if (!$con)

{

die('Could not connect: ' . mysql_error());

}mysql_select_db("cheese", $con);$sql=$sql='INSERT INTO `SkillGuides` (`author`, `title`, `skill`, `p&f`, `guide`, `credit`)
VALUES
(\''.mysql_escape_string($_COOKIE["username"]).'\',\''.mysql_escape_string($_POST['title']).'\',\''.mysql_escape_string($_POST['skill']).'\',\''.mysql_escape_string($_POST['p&f']).'\',\''.mysql_escape_string($_POST['guide']).'\',\''.mysql_escape_string($_POST['credit']).'\')';
if (!mysql_query($sql,$con))

{

die('Error: ' . mysql_error());

}
mysql_close($con);
}
?>

Ok, now when someone puts a ' for something like "Cook's assistant" it will be diplayed "Cook/s assistant"
How can i fix this?

UnlimitedMB
03-30-2008, 11:31 AM
add this function and in your existing code change mysql_escape_string to mysqlstring

function mysqlstring($string){
if (get_magic_quotes_gpc()){
$string = stripslashes($string);
}
return mysql_escape_string($string);
}

destrugter
03-30-2008, 03:53 PM
Thanks a ton...it worked! :)