Jump to content

Which line is it ? (In MySQL error message number 1064)


roparzhhemon237

Recommended Posts

 I’ve just read several manual pages and forum comments on "Error number 1064" but I still don’t understand what’s going on with the problem I'm having now … Also, I'm surprised that the error message mentions two different line numbers (1 and 35).

  Here is the error message I get :

 

error_message.png


And here are the contents of my "one_more_visit_to_topic.php" file :
 

<?php

include("includes/model/database_searches/see_readings.php");
include("includes/model/database_searches/see_watchings.php");

function one_more_visit_to_topic($user_id,$topic_id)
{
    global $db;
    $request_string='UPDATE forum_topic '.
    'SET topic_vu = topic_vu + 1 WHERE topic_id = :topic';
    $query=$db->prepare($request_string);
    $query->bindValue(':topic',$topic_id,PDO::PARAM_INT);
    $query->execute();
    $query->CloseCursor();
    // Remember that topic has been read by user
    if(!(see_if_user_has_read_topic($user_id,$topic_id))) {
        $request_string='INSERT INTO forum_read (fr_topic_id,fr_user_id) '.
        'VALUES (:topic,:user)';
        $query=$db->prepare($request_string);
        $query->bindValue(':topic',$topic_id,PDO::PARAM_INT);  
        $query->bindValue(':user',$user_id,PDO::PARAM_INT);  
        $query->execute();
        $query->CloseCursor();
    }
    // If user has already received a warning by mail,
    // the "alert" value needs to be toggled in the fw_watch table
    if(see_if_user_has_been_warned($user_id,$topic_id)) {
        $request_string='UPDATE forum_read SET fw_alert = :alt '.
        'WHERE fw_topic_id = :topic AND fw_user_id= :user)';
        $query=$db->prepare($request_string);
        $query->bindValue(':topic',$topic_id,PDO::PARAM_INT);  
        $query->bindValue(':user',$user_id,PDO::PARAM_INT);
        $one=(int)1;
        $query->bindValue(':alt',$one,PDO::PARAM_INT);  
        $query->execute();
        $query->CloseCursor();
    }
    return;
}


?>

Syntax error...at line 1 refers to line 1 of your SQL query code. If you are one of those people who always stretch out there SQL code on a single line then the error will always be on line 1.

 

OTOH, if you structure you queries to make them more readable eg

SELECT 
     col1
   , col2
   , CONCAT(col3, col4) AS something
FROM tablea
    JOIN tableb USING (somekey)
ORDERBY col1

then it would report the syntax error in line 7 in the example able

 

The 35 refers to the line in the php file where the error occurred.

$request_string='UPDATE forum_read SET fw_alert = :alt '.
        'WHERE fw_topic_id = :topic AND fw_user_id= :user)';

 

Why is there a ) at the end of that query?

 

Of course, how could I be so blind? Thanks for answering my stupid question.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.