Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Help with Query

  1. #1
    New Coder
    Join Date
    Jul 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with Query

    I know this is a really newbie question but hey what can I say IM A NEWBIE.... anyway I got this IF statement that works with a query that puts data into a table but I’m trying to make that the same query put also info from another query to another table at the same time but I seem to be having problems. Here’s the code:

    PHP Code:

    $sql 
    "INSERT INTO t_info SET
        user='$user',
        data1='$data1',
        data2='$data2',
        from='$fromdate1''$fromdate2''$fromdate3',
        to='$todate1''$todate2''$todate3'"
    ;
        
    $sql2 "INSERT INTO t_login SET
        user='$user',
        pass='$pass'"
    ;
        
    if (@
    mysql_query($sql.$sql2)) {
    echo(
    '<p>New User added to Members</p>');
    } else {
    echo(
    '<p>Error adding new User: ' .
    mysql_error() . '</p>');


  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Hi,

    You can't run both in one mysql query call. You'll have to add another one for the second query. Currently, yours will try to execute a query that has both those strings concatenated together.

    Good luck;

  • #3
    New Coder
    Join Date
    Jul 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey thanks I just got one question how do I that cause I'm lost in here since my script right now checks if the query was successful and echoes something and if it fails it echoes failure, but how or where do I put the other query so that it checks if both querys were right.

  • #4
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Try:
    if(mysql_query($sql) && mysql_query($sql2))
    {
    // good
    }

    Good luck;

  • #5
    New Coder
    Join Date
    Jul 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Brandoe85 my query is working now


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •