...

View Full Version : Simple Quotation Problem



Bobafart
07-30-2007, 03:48 AM
I don't know what I am doing wrong...



$query = "select id, dateUnix, dateString, headline, permalink, body, author, authorURL, favico, sitetype, vote, verified from anews2 where newsCat=$newsType && majorNews = 1 ORDER BY dateUnix DESC LIMIT 1";



outputs:

select id, dateUnix, dateString, headline, permalink, body, author, authorURL, favico, sitetype, vote, verified from anews2 where newsCat=\'entertainment\' && majorNews = 1 ORDER BY dateUnix DESC LIMIT 1




$query = "select id, dateUnix, dateString, headline, permalink, body, author, authorURL, favico, sitetype, vote, verified from anews2 where newsCat=".$newsType." && majorNews = 1 ORDER BY dateUnix DESC LIMIT 1";



outputs:

select id, dateUnix, dateString, headline, permalink, body, author, authorURL, favico, sitetype, vote, verified from anews2 where newsCat=\'entertainment\' && majorNews = 1 ORDER BY dateUnix DESC LIMIT 1


anyone have any words of wisdom?

thanks

_Aerospace_Eng_
07-30-2007, 03:53 AM
How did the data go into the database to begin with? Did you use mysql_real_escape_string? Also if magic quotes is on and you used mysql_real_escape_string then the data was escaped twice hence the reason for the added backslashes. You could use stripslashes on the data to get rid of any added backslashes.

Bobafart
07-30-2007, 04:10 AM
Perhaps I should back up a bit.

I am trying to pass a variable in an include() -- not sure if you can do this in the first place -- can you?




<?php include("inc/newsDisplay.php?newsType='entertainment'"); ?>



can I do this? ^^^

_Aerospace_Eng_
07-30-2007, 04:18 AM
Don't know if you can but there is no need for the quotes as its already a string. Sounds like you are trying to do something similar to the OP in this thread. Check out the example I posted. It should give you some ideas.

http://www.codingforums.com/showthread.php?t=120034



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum