+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 11 to 11 of 11

Thread: SQL errors and PHP

  1. #11
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: SQL errors and PHP

    Quote Originally Posted by fguy64 View Post
    That may or may not be true, but I doesn't really answer the question.
    [...]
    VALUES('$first', '$last') and expect $first and $last to be treated as something other than text data, i.e. something other than a string of characters beginning with $, then to say single quotes within double quotes are just characters is not really illuminating.
    The important part of my answer is: "Within double quoted strings (and heredocs), variables are interpolated." The statement about single quotes is just an aside, noting that single quotes within double quotes do not function as single quotes outside of strings (i.e. single quotes do not prevent variable interpolation).

    At this point, it's not entirely clear what you're asking about. Are you asking about PHP or MySQL's handling of the string? Part of my difficulty is I'm not sure what your conceptual framework is. As you post more, the clearer it will become.

    Quote Originally Posted by fguy64 View Post
    Within the double quotes is a mySQL statement.
    within that mySQL statement is the sequence VALUES('Tom', 'Jones')
    within the single quotes is text data.
    Not exactly. Within the PHP script is a double quoted string of no particular meaning. If it contains references to variables, they are replaced by the contents of the variables (after conversion to strings, if necessary). The resulting string is passed to the function mysql_query, which sends the string to MySQL. MySQL parses it as an INSERT, and the expressions "'Tom'" and "'Jones'" are parsed as strings (the varchar type is used for tables and procedures, not expressions). PHP contains no concept of SQL, and variables and strings in SQL are completely separate from PHP variables and strings.
    Last edited by misson; 06-27-2009 at 02:59 AM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. PHP Errors
    By JAL Virtual in forum Free Hosting
    Replies: 10
    Last Post: 01-26-2009, 11:50 AM
  2. Replies: 0
    Last Post: 12-24-2008, 03:59 PM
  3. Php errors
    By Wizet in forum Free Hosting
    Replies: 1
    Last Post: 09-04-2008, 08:48 PM
  4. PHP intermediate and errors are still there
    By BritAngel in forum Free Hosting
    Replies: 4
    Last Post: 08-24-2008, 09:08 PM
  5. php errors galore
    By DMG Online in forum Scripts & 3rd Party Apps
    Replies: 9
    Last Post: 05-17-2008, 06:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers