SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    936
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    WHat is this PHP & MySQL mean?

    Code:
    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 's', 'the sacred palace', 'http://www.palace.net')' at line 1
    this is the first time i encountered this error message, what do you think this mean?

    SUPER advance thank you!

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    you probably have a single quote just in front of the s

    replace each single quote with two of them

    e.g.
    Code:
    insert into ... values ( ... , 'O''Toole' , ... )
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    is_empty(2); foofoonet's Avatar
    Join Date
    Mar 2006
    Posts
    1,000
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mysql did not like something in your sql statement.

    Echo it onto the page and see where is looks wrong, usually an unescaped ' .

    Or post it here.
    Last edited by foofoonet; Aug 23, 2006 at 05:57. Reason: Doh.......................
    Upgrading to Mysql 5? Auto-increment fields now strict
    use NULL
    Or zero or leave the field name out completely.

  4. #4
    SitePoint Guru themightystephen's Avatar
    Join Date
    Mar 2005
    Location
    England
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is actually quite a common error - it just means that your query, insert or update has incorrect syntax somewhere along the line.
    Get your heelys now at flywalk.co.uk - But what are heelys?
    Heelys are simply shoes with wheels in the heels!

    Flywalk.co.uk - The UK Heelys Retailer

  5. #5
    is_empty(2); foofoonet's Avatar
    Join Date
    Mar 2006
    Posts
    1,000
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Off Topic:

    Now that is MAD.... 3 answers in the same minute!
    Upgrading to Mysql 5? Auto-increment fields now strict
    use NULL
    Or zero or leave the field name out completely.

  6. #6
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    936
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    <?php
    require_once ("opendb.php");
    require_once ("error_messages.php");
    $COerr_msgs = new error_messages; //instantiate object

    //paging of search.php
    $title_new = $_POST['topic'];

    //get all record with related topics
    $query = "SELECT * FROM topics";
    $result = mysql_query($query) or die('Error, query failed');

    //get related topic and display it into screen
    if(preg_match("/^[ a-zA-Z0-9]+$/", $title_new)) {
    if($title_new != '' && $title_new != ' ' && $title_new != ' '){
    echo '<table border="1" width="700px">';
    while(list($id, $title, $description, $url) = mysql_fetch_array($result))
    {
    if(preg_match("/\b$title_new\b/i", $title)) {
    //fill array with related topic IDs.
    $topic_rel[] = $id;
    }
    }
    echo '</table>';
    $total_rec = count($topic_rel);
    echo "<br>Total record: <b>$total_rec <br>";
    echo "Pls. wait, page is loading...</b>";

    //Empty temporary table topics_tmp then fill again with contents from topic_rel[]
    $query = "TRUNCATE TABLE `topics_tmp`";
    mysql_query($query) or die(mysql_error());

    $total_tmp = $total_rec-1;
    for($x=0; $x<=$total_tmp; $x++){
    //select records from table TOPICS first
    $query = "SELECT * FROM topics WHERE id='$topic_rel[$x]'";
    $result = mysql_query($query) or die('Error, query failed');
    $row = mysql_fetch_array($result, MYSQL_ASSOC);
    $title_tmp = $row['title'];
    $descrip_tmp = $row['description'];
    $url_tmp = $row['url'];

    //then insert selected data into TOPICS_TMP temporary table
    $query = "INSERT INTO topics_tmp (title, description, url) VALUES ('$title_tmp', '$descrip_tmp', '$url_tmp')";
    mysql_query($query) or die(mysql_error());
    }
    }

    ?>
    <meta http-equiv="refresh" content="0;url=http://www.askjames01.com/search_box/ed_paging2.php">
    <?php
    } else {
    echo "<b>You entered invalid character(s).<b><br>";
    echo "<b>Valid characters are: space, a-z, A-Z and 0-9</b><br>";
    }
    ?>

  7. #7
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    936
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    ok what do you think those codes?
    where i was made mistakes?

    thanks

  8. #8
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $title_tmp mysql_real_escape_string ($row['title']);
    $descrip_tmp mysql_real_escape_string ($row['description']);
    $url_tmp mysql_real_escape_string ($row['url']); 
    Ian Anderson
    www.siteguru.co.uk

  9. #9
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    936
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Thanks man it works


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
  •