SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Addict Mainer82's Avatar
    Join Date
    Aug 2003
    Location
    Maine, USA
    Posts
    249
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP form and MSSQL help

    I have a PHP form that adds data to a MySQL DB, I now have to convert that PHP code so that it will work on a MSSQL DB. PHP is running fine on the server.

    Here's what I have so far, basically I changed everything that WAS mysql_ to mssql_ but it's not working. I have a line that I'm not showing that calls a config file that connects to the DB as well, I'm also not showing the HTML form unless you need it.

    PHP Code:
            <?php
                
    if (isset($_POST['vendor_id'])) { //Check for a field that is mandatory to do the inserted
                
    $vendor mssql_escape_string($_POST['vendor_id']);
                
    $name mssql_escape_string($_POST['name_id']);
                
    $version mssql_escape_string($_POST['version']);
                
    $serial = (!empty($_POST['serial'])) ? $_POST['serial'] : 'NULL';
                
    $productkey = (!empty($_POST['productkey'])) ? $_POST['productkey'] : 'NULL';
                
    $department mssql_escape_string($_POST['department']);
                
    $owner mssql_escape_string($_POST['owner']);
                
    $computer = (!empty($_POST['computer'])) ? $_POST['computer'] : 'NULL';
                
    $comments = (!empty($_POST['comments'])) ? $_POST['comments'] : 'NULL';
                
    $acquired = (!empty($_POST['acquired'])) ? $_POST['acquired'] : 'NULL';
                
    $retired mssql_escape_string($_POST['retired']);
            
    $sql "INSERT INTO dbo.keylist_detail (vendor_id,name_id,version,Serial,ProductKey,department_ID,owner,computer,Comments,acquired,retired)
                    VALUES (''
    $vendor','$name','$version',$serial','$productkey','$department','$owner','$computer','$comments','$acquired','$retired'')";
            
    mssql_query($SQL);
            if (
    mssql_query($sql)) {
                echo 
    '<strong><em>Your data has been submitted</em></strong><br /><br />';
                    } else {
                echo 
    '<p>Error adding submitted info: ' mssql_error(). '</p>';
            }
            }
            
    ?>
    Get to know the man behind the screen

  2. #2
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,332
    Mentioned
    192 Post(s)
    Tagged
    4 Thread(s)
    Is it a typing error that $SQL is uppercase in the first call but lowercase in the 'If' (as it is defined)?

    What do you get from a
    Code:
    var_dump(mssql_query($sql));
    ?

    In what way is it "not working"? Do you see any data being INSERTed into the database?
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Git is for EVERYONE
    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains

  3. #3
    SitePoint Addict Mainer82's Avatar
    Join Date
    Aug 2003
    Location
    Maine, USA
    Posts
    249
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No data is being passed through to the DB.
    Get to know the man behind the screen


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
  •