Page 1 of 1

PHP shows Question marks instead of quotes from Mysql

Posted: Sun Dec 07, 2003 12:27 pm
by asedesigns
Heres the thing... i have an article database in which inside the main article field (text) has html code inside... I have it then get the information and display it on the page. The article shows fine, but for Single ' and double " quotes they are changed to question marks instead. Anyone know why?
Heres the basic overview of the code...

Code: Select all

<?php
$idthing = $_GET['row'];
$sql = "SELECT * FROM dakovarticlelist WHERE id = " . $idthing . " ";
$result = mysql_query($sql, $mydb);
$data = mysql_fetch_array($result);


$article1 = $data["article"]; 
$title1 = $data['title'];
$author1 = $data['author'];
$aboutauthor1 = $data['aboutauthor'];
$datewritten1 = $data['datewritten'];
$dateposted1 = $data['dateposted'];
$maincateogry1 = $data['maincategory'];
$subcategory1 = $data['subcategory'];
?>

more code here..... 
then...

<?php echo $article1; ?>
[Added PHP tags for eyecandy --JAM]

i tried print article... i tried stripslashes($article1);, addslashes($article1); and single and double quotes. Anyone know what the problem might be and how to fix it ? My email is info@asedesigns.com thanks.

Posted: Sun Dec 07, 2003 2:51 pm
by mchaggis
do u have access to the databsae itself, ie can you execute the SQL statements directly on the database server. The reason I ask, is it may be the way you are inserting the data into the databse...

What is the script for getting the data into the database?

Posted: Sun Dec 07, 2003 6:25 pm
by infolock
try this and see what you get :

Code: Select all

<?php 
mysql_select_db('db_name_here'); // this is for testing purposes.  change to your database name.
$idthing = $_GET['row']; 
$sql = "SELECT * FROM dakovarticlelist WHERE id = '" . $idthing . "' "; 
$result = mysql_query($sql) or die(mySQL_Error());

while ($data = mysql_fetch_array($result))
{
	$article1 = $data['article']; 
	$title1 = $data['title']; 
	$author1 = $data['author']; 
	$aboutauthor1 = $data['aboutauthor'];
	$datewritten1 = $data['datewritten'];
	$dateposted1 = $data['dateposted'];
	$maincateogry1 = $data['maincategory'];
	$subcategory1 = $data['subcategory'];
}
echo 'article1 value is - '.$article1;
echo '<br />';
echo 'title1 value is - '.$title1;
echo '<br />';
echo 'author1 value is - '.$author1;
echo '<br />';
echo 'aboutauthor1 value is - '.$aboutauthor1;
echo '<br />';
echo 'datewritten1 value is - '.$datewritten1;
echo '<br />';
echo 'dateposted11 value is - '.$dateposted1;
echo '<br />';
echo 'maincategory1 value is - '.$maincategory1;
echo '<br />';
echo 'subcategory1 value is - '.$subcategory1;
?>

Posted: Mon Dec 08, 2003 12:35 am
by basdog22
[EDIT] :oops: :oops: [/EDIT]