...

View Full Version : Help with Query



Truz
08-03-2006, 03:42 AM
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:




$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>');
}

Brandoe85
08-03-2006, 05:29 AM
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;

Truz
08-03-2006, 04:21 PM
Hey thanks I just got one question how do I that :D 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.

Brandoe85
08-03-2006, 04:23 PM
Try:
if(mysql_query($sql) && mysql_query($sql2))
{
// good
}

Good luck;

Truz
08-03-2006, 11:26 PM
Thanks Brandoe85 my query is working now:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum