SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,761
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Text after ? in Prepared Statement

    If I place text after the question mark in my Prepared Statement, will it cause any issues?

    Code:
    	// Build query.
    	$q2 = 'SELECT m.first_name, c.created_on, c.body, c.status
    			FROM member AS m
    			INNER JOIN comment AS c
    			ON m.id = c.member_id
    			WHERE c.article_id=? AND c.status="Approved"';
    Thanks,


    Debbie

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,220
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    you're asking a php question in the mysql forum again

    i would just sidestep the issue by coding it this way --
    Code:
    WHERE c.status="Approved" AND c.article_id=?';
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,761
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    you're asking a php question in the mysql forum again

    i would just sidestep the issue by coding it this way --
    Code:
    WHERE c.status="Approved" AND c.article_id=?';
    Sure, why not be obvious?!


    Debbie

  4. #4
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    No.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  5. #5
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    As Anthony said, no, it doesn't matter at all. After all, what if you have a prepared statement with two parameters? Then you'll always have text after the first question mark.

    But did you not try to run the above query before asking your question here?

  6. #6
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,761
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Immerse View Post
    As Anthony said, no, it doesn't matter at all. After all, what if you have a prepared statement with two parameters? Then you'll always have text after the first question mark.

    But did you not try to run the above query before asking your question here?
    Yes I did.

    (Doesn't mean what I did was correct.)


    Debbie


Bookmarks

Posting Permissions

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