SitePoint Sponsor

User Tag List

Results 1 to 23 of 23

Thread: SQL Error

  1. #1
    Degrading Gracefully PalmerB's Avatar
    Join Date
    Sep 2001
    Location
    Ohio - U.S.A. Outlook: Cautiously Optimistic
    Posts
    3,283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SQL Error

    I installed a links script called MyThreads and am receiving this error when trying to add a link...
    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 '1,'BestSynthetic.com','If you\'re looking for the absolute BEST

    Apparently I'm not the only one. Any idea how I can fix this?

    Thanks for any help.

  2. #2
    Degrading Gracefully PalmerB's Avatar
    Join Date
    Sep 2001
    Location
    Ohio - U.S.A. Outlook: Cautiously Optimistic
    Posts
    3,283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone?

  3. #3
    Level 8 Chinese guy Archbob's Avatar
    Join Date
    Sep 2001
    Location
    Somewhere in this vast universe
    Posts
    3,732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could you post the query?

  4. #4
    Degrading Gracefully PalmerB's Avatar
    Join Date
    Sep 2001
    Location
    Ohio - U.S.A. Outlook: Cautiously Optimistic
    Posts
    3,283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would that be in the code for the script?

  5. #5
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by PalmerB
    Anyone?
    Impatient!

    At first glance, it looks like there is a quote missing after the first digit printed, '1, should be '1'.

    That said, I've downloaded the source, done a few searches, and I can't find a missing quote.

    Most the time the author uses this style to create inserts.:
    PHP Code:
            $su mysql_query("insert into ".$config["pre"]."waitcat (id,title,message,cat,ip) values('$id',
                        '
    $HTTP_POST_VARS[title]' ,
                        '
    $HTTP_POST_VARS[message]' ,
                        '
    $HTTP_POST_VARS[category]' ,
                        '
    $ip_addy
                    )"
    ) or die (mysql_error()); 
    If that trailing quote was omitted, that could cause your error.

    There aren't many comments in the source, so finding the correct query might be a matter of following the commands.
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  6. #6
    Degrading Gracefully PalmerB's Avatar
    Join Date
    Sep 2001
    Location
    Ohio - U.S.A. Outlook: Cautiously Optimistic
    Posts
    3,283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Sam. Sorry for the impatience, it's for a client and he would like to have it working. So if I follow what you're saying, you downloaded the zip file of the script and you couldn't find anything wrong. Correct?

  7. #7
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Off Topic:

    Quote Originally Posted by PalmerB
    Thanks Sam. Sorry for the impatience, it's for a client and he would like to have it working. So if I follow what you're saying, you downloaded the zip file of the script and you couldn't find anything wrong. Correct?
    psstt... that's why you should outsource the programming part of your clients sites. Leass headache for you
    Mike
    It's not who I am underneath, but what I do that defines me.

  8. #8
    Degrading Gracefully PalmerB's Avatar
    Join Date
    Sep 2001
    Location
    Ohio - U.S.A. Outlook: Cautiously Optimistic
    Posts
    3,283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I did it for free in trade for giving Hartmann a deal on a new truck since he crashed his.

  9. #9
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ah, well, :\
    Mike
    It's not who I am underneath, but what I do that defines me.

  10. #10
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is this version .7 you are using?
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  11. #11
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by samsm
    At first glance, it looks like there is a quote missing after the first digit printed, '1, should be '1'
    At first glance, it looks like there's a ' before the 1 that should not be there

    Quote Originally Posted by MattR
    Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL
    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  12. #12
    Degrading Gracefully PalmerB's Avatar
    Join Date
    Sep 2001
    Location
    Ohio - U.S.A. Outlook: Cautiously Optimistic
    Posts
    3,283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No I'm using .9 I believe which appears to be listed as unstable.

  13. #13
    Degrading Gracefully PalmerB's Avatar
    Join Date
    Sep 2001
    Location
    Ohio - U.S.A. Outlook: Cautiously Optimistic
    Posts
    3,283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Sean, can you fix this code then?
    PHP Code:
    <?
    # Edit me to point to the config.php3 on your PC.
    include "config.php3";
    #----------------------------------------------------------------->
    # Version: $Id: index.php3,v 1.20 2002/10/23 20:43:33 ldrolez Exp $
    # Website: [url]http://mythreads.sourceforge.net[/url]
    #
    # Desc: Main script for maintaining a links database
    #
    #
    # License: This code is released under the terms of the GNU GPL
    # version 2 or later. Please refer to [url]www.gnu.org[/url] for a copy
    # of this license.
    #
    #----------------------------------------------------------------->

    # main() : This function controls the script functions.
    function main()
    {
    include(
    "./lib/lib_main.php3");

        global 
    $tpl$allow$HTTP_GET_VARS$HTTP_COOKIE_VARS$HTTP_POST_VARS$admin_username$admin_password,$add_link,$sug_category;
        global 
    $config;

        
    # Do not report uninitialized variables
        
    error_reporting  (E_ERROR E_WARNING E_PARSE); 
        
    # Disable magic_quotes_runtime
        
    set_magic_quotes_runtime(0); 

        if( !
    get_magic_quotes_gpc() )
        {
            if( 
    is_array($HTTP_GET_VARS) )
            {
            while( list(
    $k$v) = each($HTTP_GET_VARS) )
            {
                if( 
    is_array($HTTP_GET_VARS[$k]) )
                {
                    while( list(
    $k2$v2) = each($HTTP_GET_VARS[$k]) )
                    {
                        
    $HTTP_GET_VARS[$k][$k2] = addslashes($v2);
                    }
                    @
    reset($HTTP_GET_VARS[$k]);
                }
                else
                {
                    
    $HTTP_GET_VARS[$k] = addslashes($v);
                }
            }
            @
    reset($HTTP_GET_VARS);
            }

            if( 
    is_array($HTTP_POST_VARS) )
            {
            while( list(
    $k$v) = each($HTTP_POST_VARS) )
            {
                if( 
    is_array($HTTP_POST_VARS[$k]) )
                {
                    while( list(
    $k2$v2) = each($HTTP_POST_VARS[$k]) )
                    {
                        
    $HTTP_POST_VARS[$k][$k2] = addslashes($v2);
                    }
                    @
    reset($HTTP_POST_VARS[$k]);
                }
                else
                {
                    
    $HTTP_POST_VARS[$k] = addslashes($v);
                }
            }
            @
    reset($HTTP_POST_VARS);
            }    

            if( 
    is_array($HTTP_COOKIE_VARS) )
            {
            while( list(
    $k$v) = each($HTTP_COOKIE_VARS) )
            {
                if( 
    is_array($HTTP_COOKIE_VARS[$k]) )
                {
                    while( list(
    $k2$v2) = each($HTTP_COOKIE_VARS[$k]) )
                    {
                        
    $HTTP_COOKIE_VARS[$k][$k2] = addslashes($v2);
                    }
                    @
    reset($HTTP_COOKIE_VARS[$k]);
                }
                else
                {
                    
    $HTTP_COOKIE_VARS[$k] = addslashes($v);
                }
            }
            @
    reset($HTTP_COOKIE_VARS);
            }
        }

        
    DatabaseConnect();
        
        if (isset (
    $HTTP_GET_VARS["mode"]))
        {
            if (
    $HTTP_GET_VARS["mode"] == 'search')
            {            
                include(
    "./lib/lib_search.php3");
            } 
            else if (
    $HTTP_POST_VARS["sorry_go_back"] != '')
            {
                
    showMainPage();            
            }
            else if (
    eregi("(add_link|update_link|add_category)",$HTTP_GET_VARS["mode"]))
            {        
                include(
    "./lib/lib_addupdate.php3");
            }        
            else if (
    $HTTP_GET_VARS["mode"] == 'admin')
            {    
                include(
    "./lib/lib_rdf.php3");            
                include(
    "./lib/lib_admin.php3");
            } 
            else 
            {
                
    showMainPage();
            }
            
        }     
        else if(isset (
    $HTTP_GET_VARS["count"]))
        {
            
    countIt($HTTP_GET_VARS["count"]);
        } 
        else if (isset (
    $HTTP_GET_VARS["category"]) || isset ($HTTP_GET_VARS["more"]) )
        {    
              
    # Get the content before showing the webpage
                
    if ($HTTP_GET_VARS["category"] == 'top_links')
                {
                    
    $your_current_location Message("top_links");
                    
    $category_links=Top_Hits($config["sp_max_top_links"]);
                }
                else if (
    $HTTP_GET_VARS["category"] == 'new_links')
                {    
                      
    $your_current_location Message("new_links");
                      
    $category_links=Newly_Added($config["sp_max_new_links"]);
                }
                else if (
    $HTTP_GET_VARS["category"] == 'upd_links')
                {    
                      
    $your_current_location Message("upd_links");
                      
    $category_links=Newly_Updated($config["sp_max_upd_links"]);
                }
            else if (isset (
    $HTTP_GET_VARS["more"]))
            {
                
    $your_current_location Message("details");
                
    $category_links showMore($HTTP_GET_VARS["more"], $your_current_location);
            }
                else
                {
                
    $categories viewPage($HTTP_GET_VARS["category"]);
                
    $your_current_location display_category($HTTP_GET_VARS["category"]);
                
    $category_links display_category_links($HTTP_GET_VARS["category"], $HTTP_GET_VARS["view"]);
            }

            
    # remove html tags (useful for headings, title)
            
    $your_current_location2 ereg_replace("<[^>]+>"""$your_current_location);
            
    # Sets a few variables before we parse the HTML template
            
    $tpl->set_var( array( 
                
    "ADD_LINK" => "$add_link"."&category=$HTTP_GET_VARS[category]",
                
    "SUG_CATEGORY" => "$sug_category"."&category=$HTTP_GET_VARS[category]",
                
    "SUB_CATEGORIES" => $categories,
                
    "CATEGORY_LINKS" => $category_links,
                
    "HEAD_INFO" => $your_current_location2,
                
    "INFO" => $your_current_location
            
    ));
            
            
    showStartTemplate();
                    
        }
        
        else {
            
    showMainPage();
        }

    # End Main Function

    function DatabaseConnect()
    {
        global 
    $database$host$username$password$config$mylink;    

        if (
    $config["use_pconnect"] == 1) {
            
    $mylink mysql_pconnect$host$username$password);
        } else {
            
    $mylink mysql_connect$host$username$password);
        }
            
        if (!
    $mylink)
        {
                print  
    "<h3>could not connect to database</h3>\n";
                exit;
            }
            
    mysql_select_db($database);
    }



    function 
    showStartTemplate()
    {
        global 
    $tpl;

        
    $tpl->parse("MyOutput""start");
        
    $tpl->p("MyOutput");
    }




    # Call the main function which controls everything
    main();
    ?>

  14. #14
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by seanf
    At first glance, it looks like there's a ' before the 1 that should not be there Sean
    I actually was going to mention that, but there are so many of those sorts of issues in this script that DBMS specific sql didn't seem that important. :-)

    Ah, I was looking at .7 earlier. Should have asked you for the version sooner.

    The knee-jerk solution to a .9 problem would be to first try .9.1. They might have fixed your problem and a dozen others you had not noticed yet. Or did you mean that you were using .9.1?
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  15. #15
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by samsm
    ... there are so many of those sorts of issues in this script that DBMS specific sql didn't seem that important. :-)


    Palmer - I agree with Sam, try an updated version if one is available

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  16. #16
    Degrading Gracefully PalmerB's Avatar
    Join Date
    Sep 2001
    Location
    Ohio - U.S.A. Outlook: Cautiously Optimistic
    Posts
    3,283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes I meant 0.9.1 (the latest version), sorry. I've already modified all the templates so it would be great if I didn't have to change it to the .7 version. I'm trying to get it working here...
    http://www.bestautojobs.com/links/

  17. #17
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Always go with the stable version. Lesson learned?

    Sean: In the query errors, doesn't is always place the part of the qeury which has the error in single quotes? like:
    mysql_query("SELECT * FROM table WHERE name='foo', city='bar',valid=1")
    Wouldn't that return something like (yes, too lazy to execute it )
    You have an error in your SQL syntax near 'foo', city='bar', valid=1'
    Mike
    It's not who I am underneath, but what I do that defines me.

  18. #18
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by naramation
    Sean: In the query errors, doesn't is always place the part of the qeury which has the error in single quotes?
    Hey, you're right! In that case, any number of things could be the problem. Bleh.

    You know, that would have been a tad more obvious if the script author had used double quotes for the query, which is also standard, right?
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  19. #19
    Degrading Gracefully PalmerB's Avatar
    Join Date
    Sep 2001
    Location
    Ohio - U.S.A. Outlook: Cautiously Optimistic
    Posts
    3,283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So do you guys think I should just give up and install the stable version or do you think it's fixable?

  20. #20
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by samsm
    You know, that would have been a tad more obvious if the script author had used double quotes for the query, which is also standard, right?

    Erm, I use single quotes. Double quotes go artound the entire query, so single quotes for the strings.
    Mike
    It's not who I am underneath, but what I do that defines me.

  21. #21
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Palmer: I'd go with a stable version. The templates can't be that much different, can they?
    Mike
    It's not who I am underneath, but what I do that defines me.

  22. #22
    Degrading Gracefully PalmerB's Avatar
    Join Date
    Sep 2001
    Location
    Ohio - U.S.A. Outlook: Cautiously Optimistic
    Posts
    3,283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just tried installing the stable version and as usual the thing didn't work. Couldn't even install it without continuous error messages so I'm giving up on that script. What links script would you recommend?

  23. #23
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by naramation
    Erm, I use single quotes. Double quotes go artound the entire query, so single quotes for the strings.
    I had the standard backwards. Single quotes for strings, double quotes for identifiers. Meh.
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?


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
  •