www.webdeveloper.com
Results 1 to 5 of 5

Thread: SQL error in database?

  1. #1
    Join Date
    Nov 2012
    Posts
    5

    SQL error in database?

    Hello everyone,

    I am doing a sample project right now?I am getting this error when i am edititng the record in the database.

    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 'qwer,companyname='qwer' WHERE id='15'' at line 1


    Please can anyone resolve me?


    thanks in advance,
    simbu.

  2. #2
    Join Date
    Oct 2012
    Location
    Gujarat, India.
    Posts
    35
    can you post your code? Whole code...

  3. #3
    Join Date
    Nov 2012
    Posts
    5
    I mean you are asking which code?

    here i posted my search.php code

    <html>
    <head>

    </head>
    <body>
    <center><h2>Search engine</h2>
    <form action="sim.php" method="get" >
    <input type="text" name="k" size="100" value="<?php echo $_GET['k']; ?>" />
    <input type='submit' value='search' />
    </form>
    </center>

    <?php

    $k=$_GET['k'];
    $terms=explode("",'$k');
    $query="SELECT * FROM form";
    foreach($terms as $each)
    {
    $i++;
    if($i==1)
    $query .="keywords LIKE '%$each%'";
    else
    $query .="OR keywords LIKE '%$each%'";
    }

    //connect th edatabase
    mysql_connect("localhost","root","");
    mysql_select_db("han");
    $query=mysql_query($query);
    $numrows=mysql_num_rows($query) or die(mysql_error());
    if(numrows>0)
    {
    while($row=mysql_fetch_assoc($query))
    {
    $id=$row['id'];
    $fname=$row['fname'];
    $name=$row['name'];
    $currentdesignation=$row['currentdesignation'];
    $currentemployer=$row['currentemployer'];

    echo "<h2><a href=''>$fname</a></h2>$name<br /><br />";
    }
    }
    else
    echo "No results found for '<b>$k</b>' ";

    mysql_close();
    ?>

    Please help me i am struggling now.


    thanks ,
    simbu.

  4. #4
    Join Date
    Jul 2012
    Location
    Vancouver
    Posts
    61
    That error is not from that code...

    You're also missing the where clause in the search.php page though. that would probably help.. but again, that's a pull query and your error is on an update which isnt in that code you posted..

    Whereever that error is, it's missing a quote in the value though.. you have an unterminted value (qwer) qwer,companyname='qwer'..

    it should be sqlstring...qwer', companyname='qwer' where id='15'

  5. #5
    Join Date
    Nov 2012
    Posts
    5
    Thanks for ur response....Got it.....Once againg thanks.

Thread Information

Users Browsing this Thread

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

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