SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    011110010110000101111001 jabird's Avatar
    Join Date
    Aug 2004
    Location
    U.S.
    Posts
    593
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A couple MySQL/PHP errors...

    Error No.1

    First, I have:
    PHP Code:
    if(mysql_query($usertable || $newstable || $menutable)) {
        echo(
    "<br /><a href='install2.php'>Next Step</a>");
    } else {
        echo(
    'Please fix any error(s) received above, to continue.');

    That is in install1.php, when I browse there, it shows:

    This page will attempt to create the MySQL Tables for you.
    User table successfully created!
    News table successfully created!
    Menu table successfully created!
    Please fix any error(s) received above, to continue.

    and if the tables are already there, it errors out as it should...

    But when all 3 are successful, it should show "Next Step" not the error... how can I check if multiple MySQL queries where successful?

    Error No.2
    (Several MySQL errors are in here, but I believe they're all basically the same, so I'll only post the two that are different, the rest are duplicates with slightly different data...)

    No.1
    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 ''Sample',
    NOW(),
    'About',
    'If you're the admin, you can put something in here' at line 3
    No. 2

    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 ''Home', 'http://90.10.10.35/jabirdcms/index.php', '1', '0', '0', '0', '0', '0')' at line 1
    Thanks,
    ~Jabird
    Jabird.com
    If I were binary... I'd be all 1's for you.
    BBCode trouble?

  2. #2
    SitePoint Addict Adam A Flynn's Avatar
    Join Date
    Jul 2004
    Location
    Canada
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First error:
    Look at the part where it says 'If you're the admin, yuo can put something in here'. The ' in the word "you're" is being read as the end of that bit of data to be inserted, and MySQL has no idea what "re the admin, yuo can put something in here" is supposed to be. Either make that single quote a backquote (`) or escape it, making it \'

    Error 2:
    The part MySQL extracted looks fine to me, I'd have to see the full query. Check to see that you don't have 1 more value than you do column to insert.

  3. #3
    011110010110000101111001 jabird's Avatar
    Join Date
    Aug 2004
    Location
    U.S.
    Posts
    593
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1st:
    I escaped them all, and now I just get:
    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 ''Sample',
    NOW(),
    'About',
    'If you\'re the admin, you can put something in her' at line 3
    Line 3 is: 'About', not the line after that (I think)

    error2:

    PHP Code:
    <p>This page will attempt to insert sample data into MySQL for you.</p>
    <?php
    include('../includes/db.php');
    // Sample News 1
    $about "INSERT INTO news(author, date, newstitle, newstext, category) 
        (
        'Sample',
        NOW(),
        'About',
        'If you\'re the admin, you can put something in here by loging on. If you\'re not the admin, I\'m sure he/she will be along any time now, to delete me, so farewell, incase we don\'t talk again.',
        'index'
        )"
    ;
    if(
    mysql_query($about)) {
        echo(
    "The 'About' entry was successfull");
    } else {
        echo(
    "For some reason we could not enter the 'About' entry to the database.<br />The error we received was:<br /><textarea cols='40' rows='5'>".mysql_error()."</textarea><br /><br />");
        
    $aboutfail "DELETE FROM news";
    }
    // Sample News 2
    $where "INSERT INTO news(author, date, newstitle, newstext, category) 
        (
        'Sample',
        NOW(),
        'Where am I?',
        'I was built in a small town, that is called, Dongola. By someone who goes by the name of Ja (imagine a y at the end of that, and you'll know how to pronounce it). His real name is Jacob, and he works for a familly owned computer store named, C &amp; S Consulting. Ja, was 15 years old when this part here was typed, but 16 days after that, he would turn 16. I know, I know, the section was titled &quot;Where am I?&quot; but I got carried away, and most of this should have been in the &quot;About&quot; section, but what I put there, had nothing to do with &quot;About&quot; but I put it there anyway.',
        'index'
        )"
    ;
    if(
    mysql_query($where)) {
        echo(
    "The 'Where am I?' entry was successfull");
    } else {
        echo(
    "For some reason we could not enter the 'Where am I?' entry to the database.<br />The error we received was:<br /><textarea cols='40' rows='5'>".mysql_error()."</textarea><br /><br />");
        
    $wherefail "DELETE FROM news";
    }
    // Sample News 3
    $what "INSERT INTO news(author, date, newstitle, newstext, category) ('Sample', NOW(), 'What to do next...', 'Well I'm assuming you're the admin, so if you are, incase you haven't noticed... Your site is pretty uhmmm bland? if you want to fix that, go back to the documentation I'm sure you followed to get this far, and go to the next section. That should teach you how to delete me, or change me. And the section after that, teaches you how to make me 'pretty'.</p><p>Also, if you ever get to a point where you just can't go any farther, or don't feel like learning this, you can always contact me (email provided at <a href='http://www.jabird.com'>my website</a>) and I would gladly give you a quote, or do it for free, depending on the complexity of it.', 'index')";
    if(
    mysql_query($what)) {
        echo(
    "The 'What to do next...' entry was successfull");
    } else {
        echo(
    "For some reason we could not enter the 'What to do next...' entry to the database.<br />The error we received was:<br /><textarea cols='40' rows='5'>".mysql_error()."</textarea><br /><br />");
        
    $whatfail "DELETE FROM news";
    }
    // Sample Menu 1
    $home "INSERT INTO menu(name, url, position, is_delete, admin, author, is_logged_in, is_logged_out) ('Home', 'http://" $domain .'/'$path "/index.php', '1', '0', '0', '0', '0', '0')";
    if(
    mysql_query($home)) {
        echo(
    "Successfully entered the 'Home' link to the database.");
    } else {
        echo(
    "For some reason the 'Home' link could not be added to the database.<br />The error we received was:<br /><textarea cols='40' rows='5'>".mysql_error()."</textarea><br /><br />");
        
    $homefail "DELETE FROM menu";
    }
    // Sample Menu 2
    $admin "INSERT INTO menu(name, url, position, is_delete, admin, author, is_logged_in, is_logged_out) ('Admin', 'http://" $domain .'/'$path "/admin.php', '2', '0', '1', '0', '0', '0')";
    if(
    mysql_query($admin)) {
        echo(
    "Successfully entered the 'Admin' link to the database.");
    } else {
        echo(
    "For some reason the 'Admin' link could not be added to the database.<br />The error we received was:<br /><textarea cols='40' rows='5'>".mysql_error()."</textarea><br /><br />");
        
    $adminfail "DELETE FROM menu";
    }
    // Sample Menu 3
    $user "INSERT INTO menu(name, url, position, is_delete, admin, author, is_logged_in, is_logged_out) ('User CP', 'http://" $domain .'/'$path "/usercp.php', '3', '0', '0', '1', '0', '0')";
    if(
    mysql_query($user)) {
        echo(
    "Successfully entered the 'User CP' link to the database.");
    } else {
        echo(
    "For some reason the 'User CP' link could not be added to the database.<br />The error we received was:<br /><textarea cols='40' rows='5'>".mysql_error()."</textarea><br /><br />");
        
    $userfail "DELETE FROM menu";
    }
    // Sample Menu 4
    $login "INSERT INTO menu(name, url, position, is_delete, admin, author, is_logged_in, is_logged_out) ('Login', 'http://" $domain .'/'$path "/login.php', '4', '0', '0', '0', '0', '1')";
    if(
    mysql_query($login)) {
        echo(
    "Successfully entered the 'Login' link to the database.");
    } else {
        echo(
    "For some reason the 'Login' link could not be added to the database.<br />The error we received was:<br /><textarea cols='40' rows='5'>".mysql_error()."</textarea><br /><br />");
        
    $loginfail "DELETE FROM menu";
    }
    // Sample Menu 5
    $logout "INSERT INTO menu(name, url, position, is_delete, admin, author, is_logged_in, is_logged_out) ('Logout', 'http://" $domain .'/'$path "/logout.php', '5', '0', '0', '0', '1', '0')";
    if(
    mysql_query($logout)) {
        echo(
    "Successfully entered the 'Logout' link to the database.");
    } else {
        echo(
    "For some reason the 'Logout' link could not be added to the database.<br />The error we received was:<br /><textarea cols='40' rows='5'>".mysql_error()."</textarea><br /><br />");
        
    $logoutfail "DELETE FROM menu";
    }
    if(
    mysql_query($about && $where && $what && $home && $admin && $user && $login && $logout)) {
        echo(
    "<br /><a href='install3.php'>Next Step</a>");
    } else {
        echo(
    'Please fix any error(s) received above to continue.');
    }
    ?>
    is the entire script...
    ~Jabird
    Jabird.com
    If I were binary... I'd be all 1's for you.
    BBCode trouble?

  4. #4
    011110010110000101111001 jabird's Avatar
    Join Date
    Aug 2004
    Location
    U.S.
    Posts
    593
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyone?
    ~Jabird
    Jabird.com
    If I were binary... I'd be all 1's for you.
    BBCode trouble?

  5. #5
    PHP/Rails Developer Czaries's Avatar
    Join Date
    May 2004
    Location
    Central USA
    Posts
    806
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sometimes MySQL throws an error if you are using a reserved column name, but it will not tell you this is the error. I have run into a few myself. Please post your db schema so I can see if that is the problem.

  6. #6
    011110010110000101111001 jabird's Avatar
    Join Date
    Aug 2004
    Location
    U.S.
    Posts
    593
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Tables in CMS:
    menu
    news
    users

    Menu Table:
    id
    name
    url
    position
    is_delete

    News Table:
    id
    author
    date
    newstitle
    newstext
    category

    Users Table:
    id
    username
    password
    registerdate
    admin
    author
    ~Jabird
    Jabird.com
    If I were binary... I'd be all 1's for you.
    BBCode trouble?

  7. #7
    011110010110000101111001 jabird's Avatar
    Join Date
    Aug 2004
    Location
    U.S.
    Posts
    593
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm pretty sure its not conflicting tables (I installed all these tables through a PHP script) and I had to change a few of them because it gave me errors...
    ~Jabird
    Jabird.com
    If I were binary... I'd be all 1's for you.
    BBCode trouble?

  8. #8
    011110010110000101111001 jabird's Avatar
    Join Date
    Aug 2004
    Location
    U.S.
    Posts
    593
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can anyone assist me here?
    ~Jabird
    Jabird.com
    If I were binary... I'd be all 1's for you.
    BBCode trouble?

  9. #9
    011110010110000101111001 jabird's Avatar
    Join Date
    Aug 2004
    Location
    U.S.
    Posts
    593
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nevermind, I figured that one out =\

    Now I have a ) inside one of my queries, and mysql keeps thinking it ends there, but it doesn't, I've tried html character code "&#41" but it still rendered that, THEN it tried to submit that to the DB... how can I make this work?
    ~Jabird
    Jabird.com
    If I were binary... I'd be all 1's for you.
    BBCode trouble?

  10. #10
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Run your data through [fphp]mysql_real_escape_string[/php].

    POst your query with the ")."

  11. #11
    011110010110000101111001 jabird's Avatar
    Join Date
    Aug 2004
    Location
    U.S.
    Posts
    593
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $where "INSERT INTO news
        (author, date, newstitle, newstext, category) VALUES (
        'Sample',
        NOW(),
        'Where am I?',
        'I was built in a small town, that is called, Dongola. By someone who goes by the name of Ja (imagine a y at the end of that, and you'll know how to pronounce it). His real name is Jacob, and he works for a familly owned computer store named, C &amp; S Consulting. Ja, was 15 years old when this part here was typed, but 16 days after that, he would turn 16. I know, I know, the section was titled &quot;Where am I?&quot; but I got carried away, and most of this should have been in the &quot;About&quot; section, but what I put there, had nothing to do with &quot;About&quot; but I put it there anyway.',
        'index'
        )"

    ~Jabird
    Jabird.com
    If I were binary... I'd be all 1's for you.
    BBCode trouble?

  12. #12
    011110010110000101111001 jabird's Avatar
    Join Date
    Aug 2004
    Location
    U.S.
    Posts
    593
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Still having the error where:

    PHP Code:
    if(mysql_query($about && $where && $what && $home && $admin && $user && $login && $logout)) {
        echo(
    "<br /><a href='install3.php'>Next Step</a>");
    } else {
        echo(
    'Please fix any error(s) received above to continue.');

    is always failed.

    Still having the ) error...
    ~Jabird
    Jabird.com
    If I were binary... I'd be all 1's for you.
    BBCode trouble?


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
  •