Results 1 to 3 of 3

Thread: MSSQL error: The name "XXX" is not permitted in this context...

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    4

    Exclamation MSSQL error: The name "XXX" is not permitted in this context...

    Ok, so now I solved my last issue, but have hit the wall with this one... The following code produces this error:

    MSSQL error: The name "XXX" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.

    PHP Code:
    $sql 'INSERT INTO tbl_jobs VALUES (';
    $sql .= $_POST["company"];
    $sql .= ',';
    $sql .= $_POST["location"];
    $sql .= ',';
    $sql .= $_POST["title"];
    $sql .= ',';
    $sql .= $_POST["desc"];
    $sql .= ',';
    $sql .= $_POST["exper"];
    $sql .= ',';
    $sql .= $_POST["edu"];
    $sql .= ',';
    $sql .= $_POST["link"];
    $sql .= ')'
    In my troubleshooting, I verified that the variables are passing correctly, but it's treating it like a column name (according to the error). According to what I have seen, the syntax looks ok, but again, I am confused. I have googled this, but no luck so far.
    Last edited by mjkomidar; 01-06-2010 at 08:38 AM.

  2. #2
    Muslim Overclocker
    Join Date
    May 2005
    Location
    Canada
    Posts
    2,786
    Quote Originally Posted by mjkomidar View Post
    Ok, so now I solved my last issue, but have hit the wall with this one... The following code produces this error:

    MSSQL error: The name "XXX" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.

    PHP Code:
    $sql 'INSERT INTO tbl_jobs VALUES (';
    $sql .= $_POST["company"];
    $sql .= ',';
    $sql .= $_POST["location"];
    $sql .= ',';
    $sql .= $_POST["title"];
    $sql .= ',';
    $sql .= $_POST["desc"];
    $sql .= ',';
    $sql .= $_POST["exper"];
    $sql .= ',';
    $sql .= $_POST["edu"];
    $sql .= ',';
    $sql .= $_POST["link"];
    $sql .= ')'
    In my troubleshooting, I verified that the variables are passing correctly, but it's treating it like a column name (according to the error). According to what I have seen, the syntax looks ok, but again, I am confused. I have googled this, but no luck so far.
    This is not how php should be. You should listen to W1zzard's advise and keep it all in one string.

    Second, strings need to be surrounded with single quotes which you haven't done. Show me your output.

    My watercooling experience

    Water
    Scythe Gentle Typhoons 120mm 1850RPM
    Thermochill PA120.3 Radiator
    Enzotech Sapphire Rev.A CPU Block
    Laing DDC 3.2
    XSPC Dual Pump Reservoir
    Primochill Pro LRT Red 1/2"
    Bitspower fittings + water temp sensor

    Rig
    E8400 | 4GB HyperX PC8500 | Corsair HX620W | ATI HD4870 512MB


    I see what I see, and you see what you see. I can't make you see what I see, but I can tell you what I see is not what you see. Truth is, we see what we want to see, and what we want to see is what those around us see. And what we don't see is... well, conspiracies.



  3. #3
    Xtreme X.I.P. Particle's Avatar
    Join Date
    Apr 2008
    Location
    Kansas
    Posts
    3,219
    Single quotes. Escape any single quotes in the values themselves by converting them to double single quotes. That'll fix you in no time.
    Particle's First Rule of Online Technical Discussion:
    As a thread about any computer related subject has its length approach infinity, the likelihood and inevitability of a poorly constructed AMD vs. Intel fight also exponentially increases.

    Rule 1A:
    Likewise, the frequency of a car pseudoanalogy to explain a technical concept increases with thread length. This will make many people chuckle, as computer people are rarely knowledgeable about vehicular mechanics.

    Rule 2:
    When confronted with a post that is contrary to what a poster likes, believes, or most often wants to be correct, the poster will pick out only minor details that are largely irrelevant in an attempt to shut out the conflicting idea. The core of the post will be left alone since it isn't easy to contradict what the person is actually saying.

    Rule 2A:
    When a poster cannot properly refute a post they do not like (as described above), the poster will most likely invent fictitious counter-points and/or begin to attack the other's credibility in feeble ways that are dramatic but irrelevant. Do not underestimate this tactic, as in the online world this will sway many observers. Do not forget: Correctness is decided only by what is said last, the most loudly, or with greatest repetition.

    Rule 3:
    When it comes to computer news, 70% of Internet rumors are outright fabricated, 20% are inaccurate enough to simply be discarded, and about 10% are based in reality. Grains of salt--become familiar with them.

    Remember: When debating online, everyone else is ALWAYS wrong if they do not agree with you!

    Random Tip o' the Whatever
    You just can't win. If your product offers feature A instead of B, people will moan how A is stupid and it didn't offer B. If your product offers B instead of A, they'll likewise complain and rant about how anyone's retarded cousin could figure out A is what the market wants.

Tags for this Thread

Bookmarks

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
  •