Results 1 to 5 of 5

Thread: MSSQL error: Invalid pseudocolumn "$_POST"

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

    Question MSSQL error: Invalid pseudocolumn "$_POST"

    I have used MySQL and PHP for sever years with no problems, but this is my first time using MSSQL and PHP and I am having some trouble and can't seem to figure out what is wrong.

    When running the follow script/SQL query, I get --> MSSQL error: Invalid pseudocolumn "$_POST"


    $server = '***';

    $connect = mssql_connect($server, 'sa', '***');

    mssql_select_db('db_jobs', $connect);

    $sql = 'INSERT INTO tbl_jobs VALUES
    (
    $_POST["id"],
    $_POST["company"],
    $_POST["location"],
    $_POST["title"],
    $_POST["desc"],
    $_POST["exper"],
    $_POST["edu"],
    $_POST["link"]
    )';

    $query = mssql_query($sql);

    if (!$query)
    {
    die('MSSQL error: ' . mssql_get_last_message());
    }


    What is the problem?

    It goes without saying that I'm able to connect to my server and perform other simple tasks, like create the database and tables using php, but I can't add data using the above script.

  2. #2
    Muslim Overclocker
    Join Date
    May 2005
    Location
    Canada
    Posts
    2,786
    PHP Code:
    $sql 'INSERT INTO tbl_jobs VALUES 
    (
    {$_POST["id"]},
    {$_POST["company"]},
    {$_POST["location"]},
    {$_POST["title"]},
    {$_POST["desc"]},
    {$_POST["exper"]},
    {$_POST["edu"]},
    {$_POST["link"]}
    )'

    When debugging, print out your strings:

    PHP Code:
    echo $sql
    If you have issues with the above, try swapping the " with ' and vice versa.

    Quote Originally Posted by mjkomidar View Post
    I have used MySQL and PHP for sever years with no problems, but this is my first time using MSSQL and PHP and I am having some trouble and can't seem to figure out what is wrong.

    When running the follow script/SQL query, I get --> MSSQL error: Invalid pseudocolumn "$_POST"


    $server = '***';

    $connect = mssql_connect($server, 'sa', '***');

    mssql_select_db('db_jobs', $connect);

    $sql = 'INSERT INTO tbl_jobs VALUES
    (
    $_POST["id"],
    $_POST["company"],
    $_POST["location"],
    $_POST["title"],
    $_POST["desc"],
    $_POST["exper"],
    $_POST["edu"],
    $_POST["link"]
    )';

    $query = mssql_query($sql);

    if (!$query)
    {
    die('MSSQL error: ' . mssql_get_last_message());
    }


    What is the problem?

    It goes without saying that I'm able to connect to my server and perform other simple tasks, like create the database and tables using php, but I can't add data using the above script.
    Last edited by ahmad; 01-03-2010 at 06:45 PM.

    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 Legend
    Join Date
    Jan 2003
    Location
    Stuttgart, Germany
    Posts
    929
    replace the ' around the sql statement with ". ' means no parsing of $... inside the text.
    also put "" around the inserted variables

  4. #4
    Registered User
    Join Date
    Dec 2009
    Posts
    4
    Here is the code that resolved my issue:

    $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 .= ')';


    HOWEVER, this now causes a new error which I will post in another post.

  5. #5
    Registered User
    Join Date
    Dec 2009
    Posts
    4
    I am just amazed at the differences between MSSQL and MySQL when it comes to PHP. Oy!

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
  •