www.webdeveloper.com
Results 1 to 3 of 3

Thread: need help error sql

Hybrid View

  1. #1
    Join Date
    May 2012
    Posts
    1

    need help error sql

    master,

    i have a problem with my homework,
    have an error like this :

    "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order o, detail_order d, member m, buku b WHERE o.id_order=d.id_' at line 5"

    this my script :

    <?php

    $GIDOrder=$_SESSION['id_order'];
    $DataStatus=array("baru","lunas","terkirim");

    $QOrder=mysql_query("SELECT o.id_order, o.tanggal, o.status,
    d.jumlah,
    b.isbn, b.judul, b.harga,
    m.nama, m.alamat, m.Kota
    FROM order o, detail_order d, member m, buku b
    WHERE
    o.id_order=d.id_order
    AND m.id_member=o.id_member
    AND level='member'
    AND d.isbn=b.isbn
    AND o.id_order='".$GIDOrder."'
    ") OR DIE(mysql_error());


    if(mysql_num_rows($QOrder)){
    echo "<table align='center' width='610'>
    <tr bgcolor='#d8dfea'><th colspan='6'>Informasi Produk</th></tr>
    <tr bgcolor='#92a751'><th>No</th><th>ISBN</th><th>Buku</th><th>Harga</th><th>Jml</th><th>Subtotal</th>
    </tr>";
    $Tot=0;
    $No=1;
    while($r=mysql_fetch_array($QOrder)){
    $IDOrder=$r['id_order'];
    $TglOrder=$r['tanggal'];
    $StatusOrder=$r['status'];
    $JmlBeli=$r['jumlah'];
    $ISBN=$r['isbn'];
    $Harga=$r['harga'];
    $Judul=$r['judul'];
    $NamaLengkap=$r['nama'];
    $Alamat=$r['alamat'];
    $Kota=$r['kota'];
    $SubTotal=$Harga*$JmlBeli;
    $Tot=$Tot+$SubTotal;

    if($No % 2==0){
    echo "<tr bgcolor='#d8dfea'>";
    }
    else {
    echo "<tr bgcolor='#edeff4'>";
    }
    echo "<td>$No</td><td>$ISBN</td><td>$Judul</td><td>Rp ".number_format($Harga,2,",",".")."</td><td>$JmlBeli</td><td align='right'>Rp ".number_format
    ($SubTotal,2,",",".")."</td></tr>";

    $No++;
    }
    echo "<tr bgcolor='#92a751'><th colspan='4' align='right'>Total</th><th colspan='2' align='right'>Rp ".number_format($Tot,2,",",".")."</th></tr>";
    echo "<tr><td colspan='6' height='20'>&nbsp;</td></tr>
    <tr bgcolor='#d8dfea'><th colspan='6'>Informasi Pembeli</th></tr>
    <tr bgcolor='#edeff4'><td colspan='3'>ID Order</td><td colspan='3'>$IDOrder</td></tr>
    <tr bgcolor='#d8dfea'><td colspan='3'>Tanggal</td><td colspan='3'>$TglOrder</td></tr>
    <tr bgcolor='#edeff4'><td colspan='3'>Nama</td><td colspan='3'>$NamaLengkap</td></tr>
    <tr bgcolor='#edeff4'><td colspan='3'>Kota</td><td colspan='3'>$Kota</td></tr>
    <tr bgcolor='#d8dfea'><td colspan='3'>Alamat</td><td colspan='3'>$Alamat</td></tr>
    <tr bgcolor='#edeff4'><td colspan='3'>Status</td><td colspan='3'>

    <form action='$_SERVER[PHP_SELF]?page=order&act=proses' method='POST'>
    <input type='hidden' name='id_order' value='$IDOrder'>
    ";

    foreach($DataStatus AS $Key=>$Val){

    if($StatusOrder==$Val){
    echo "".strtoupper($Val)."";
    }

    }

    echo "</td></tr>
    </table>

    ";
    }
    else
    {
    echo '<meta http-equiv="refresh" content="0;url=index.php">';
    exit;
    }
    ?>

    please help master

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,923
    Just a guess: it might consider "order" to be a reserved word (such as in an ORDER BY expression), so try wrapping it in `back-quotes` to tell the SQL parser it's an identifier.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Mar 2006
    Location
    Discworld
    Posts
    75
    I would not even guess.
    ORDER is a reserved word and could not be used as a table name.
    Same goes for member. On some SQL databases (depend on version) it is a reserved word.
    Rename tables, period.
    make it as your habbit to use naming convention such as table name looks like this tbl_NAME_of_your_choice.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles