Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Dec 2006
    Posts
    417
    Thanks
    168
    Thanked 1 Time in 1 Post

    Simple Quotation Problem

    I don't know what I am doing wrong...

    Code:
    	$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


    Code:
    	$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

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Regular Coder
    Join Date
    Dec 2006
    Posts
    417
    Thanks
    168
    Thanked 1 Time in 1 Post
    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?

    Code:
    <?php include("inc/newsDisplay.php?newsType='entertainment'"); ?>
    can I do this? ^^^

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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.

    Using parameters and query
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •