PHP shows Question marks instead of quotes from Mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
asedesigns
Forum Newbie
Posts: 1
Joined: Sun Dec 07, 2003 12:27 pm

PHP shows Question marks instead of quotes from Mysql

Post 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.
User avatar
mchaggis
Forum Contributor
Posts: 150
Joined: Mon Mar 24, 2003 10:31 am
Location: UK

Post 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?
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post 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;
?>
basdog22
Forum Contributor
Posts: 158
Joined: Sun Nov 30, 2003 3:03 pm
Location: Greece

Post by basdog22 »

[EDIT] :oops: :oops: [/EDIT]
Post Reply