You have an error in your SQL syntax

Discussion in 'PHP' started by JCOnline, Jan 6, 2013.

  1. #1
    Hi friends,

    Once switched server have received the following error: "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 '' at line 1"
    MySQL version OK: 5.1.63-rel13.4-log
    MySQL version ERROR: 5.1.66-cll


    The problems are the following excerpts:

      <?php
                                            $today_coupons = $data->select ( "Coupon" , "*" , array ( "IsFeatured" => 1 ) , 0 , $app_init_data["FeaturedCouponsHome"] , "DateAdded desc" ) ;
                                            if ( ! empty ( $today_coupons ) )
                                                    foreach ( $today_coupons as $coupon ) :
                                                    
                                                            $web_detail = $data->select ( "Website" , "*" , array ( "WebsiteID" => $coupon["WebsiteID"] ) ) ;
                                                            if ( empty ( $web_detail ) )
                                                                    continue ;
                                                            $web_detail = $web_detail[0] ;
                                    ?>
    PHP:
    and

    
                            <?php
                                    $featured_web = $data->select ( "Website" , "*" , array ( "IsFeatured" => 1 ) , 0 , $app_init_data["FeaturedStoresHome"] , " DateAdded desc" ) ;
                                    if ( ! empty ( $featured_web ) )
                                    {
                                            $count_rec = count ( $featured_web ) ;
                            ?>
    
    PHP:
    What can I change to fix the problem?
     
    JCOnline, Jan 6, 2013 IP
  2. vineld

    vineld Greenhorn

    Messages:
    53
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    18
    #2
    To easier locate the problem it would make sense to print the query itself. That always makes it much easier to troubleshoot sql queries (and many other issues).
     
    vineld, Jan 6, 2013 IP
  3. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #3
    Sounds to me as if the location of the database is different on this server than it was on the old one. Find out where the database is, then rewrite your code or reset your configuration for the new location. (You're not showing the database connection code, so we can't tell you what to change in it.)
     
    Rukbat, Jan 6, 2013 IP