Carter
Carter

Reputation: 1037

PHP SQL UPDATE Query issue

I'm having trouble with this update query.INSERT works absolutely fine.My INSERT query and UPDATE query as follows,

This is the error that i've been getting.

db_exec:DB Error: 
 (UPDATE vms2 set invoiceid='', slicenseinfo='testVM',  
   manufacturerid='692', hyp='6', stitle='UBER', vmg='UBER', sversion='1716',  sinfo='', 
   purchdate='1367712000', licqty='7', lictype='192', dns='', ipv4='10.2.36.3', ipv4dns='102.32.3.55', 
    remip='110.2.3.3', remipdns='100.32.3.32', ipv6='', 
    hdd='', ram='', cores='',  WHERE id=14): 
    near "WHERE": syntax error


Array
(
    [0] => Array
        (
            [file] => C:\xampp\htdocs\test\php\editvm.php
            [line] => 149
            [function] => db_exec
            [args] => Array
                (
                    [0] => PDO Object
                        (
                        )

                    [1] => UPDATE vms2 set invoiceid='', slicenseinfo='testVM',  manufacturerid='692', hyp='6', stitle='UBER', vmg='UBER', sversion='1716',  sinfo='', purchdate='1367712000', licqty='7', lictype='192', dns='', ipv4='10.2.36.3', ipv4dns='102.32.3.55', remip='110.2.3.3', remipdns='100.32.3.32', ipv6='', hdd='', ram='', cores='',  WHERE id=14
                )

        )

    [1] => Array
        (
            [file] => C:\xampp\htdocs\test\index.php
            [line] => 490
            [args] => Array
                (
                    [0] => C:\xampp\htdocs\test\php\editvm.php
                )

            [function] => require
        )

)

Thanks for your help :)

Upvotes: 1

Views: 64

Answers (3)

Sobin Augustine
Sobin Augustine

Reputation: 3775

Update the UPDATE command to this

 UPDATE vms2 set invoiceid='', slicenseinfo='testVM',  manufacturerid='692', hyp='6', stitle='UBER', vmg='UBER', sversion='1716',  sinfo='', purchdate='1367712000', licqty='7', lictype='192', dns='', ipv4='10.2.36.3', ipv4dns='102.32.3.55', remip='110.2.3.3', remipdns='100.32.3.32', ipv6='', hdd='', ram='', cores=''  WHERE id=14`

Upvotes: 0

aaron
aaron

Reputation: 687

You have an extra comma before the Where clause which is not required

UPDATE vms2 set invoiceid='', slicenseinfo='testVM',  manufacturerid='692', hyp='6', stitle='UBER', vmg='UBER', sversion='1716',  sinfo='', purchdate='1367712000', licqty='7', lictype='192', dns='', ipv4='10.2.36.3', ipv4dns='102.32.3.55', remip='110.2.3.3', remipdns='100.32.3.32', ipv6='', hdd='', ram='', cores=''  WHERE id=14

This should work.

Upvotes: 0

calcinai
calcinai

Reputation: 2617

Remove the last comma before the WHERE

Upvotes: 1

Related Questions