onthespot Posted August 15, 2009 Share Posted August 15, 2009 This is my code <?php $query="UPDATE ".TBL_USERS." SET userlevel = 1 WHERE username = '$user'"; $stats1 = "INSERT INTO fifa09_stats VALUES ('$user', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0')"; $stats2 = "INSERT INTO fifa10_stats VALUES ('$user', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0')"; $stats3 = "INSERT INTO pes09_stats VALUES ('$user', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0')"; $stats4 = "INSERT INTO pes10_stats VALUES ('$user', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0')"; if (md5($user) == $act){ mysql_query($query); mysql_query($stats1); mysql_query($stats2); mysql_query($stats3); mysql_query($stats4); echo "Congratulations, activation complete. You may now log in and enjoy all of our features."; } else { echo "We are sorry, but this activation request doesn't exist"; } ?> The $query variable works perfect, but the other 4 don't work? Any ideas? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted August 15, 2009 Share Posted August 15, 2009 There are at least three or more different reasons the queries could be failing. You would need to use mysql_error to get php/mysql to tell you why each query failed. Quote Link to comment Share on other sites More sharing options...
onthespot Posted August 15, 2009 Author Share Posted August 15, 2009 <?php $query="UPDATE ".TBL_USERS." SET userlevel = 1 WHERE username = '$user'"; $stats1 = "INSERT INTO fifa09_stats VALUES ('$user', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0')"; $stats2 = "INSERT INTO fifa10_stats VALUES ('$user', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0')"; $stats3 = "INSERT INTO pes09_stats VALUES ('$user', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0')"; $stats4 = "INSERT INTO pes10_stats VALUES ('$user', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0')"; if (md5($user) == $act){ mysql_query($query) or die(mysql_error()); mysql_query($stats1) or die(mysql_error()); mysql_query($stats2) or die(mysql_error()); mysql_query($stats3) or die(mysql_error()); mysql_query($stats4) or die(mysql_error()); echo "Congratulations, activation complete. You may now log in and enjoy all of our features."; } else { echo "We are sorry, but this activation request doesn't exist"; } ?> I changed the code to that, and ran it, didn't get an error, but still didn't populate the tables? Quote Link to comment Share on other sites More sharing options...
waynew Posted August 15, 2009 Share Posted August 15, 2009 That style of insert is... basically bad. What if you want to add a column to your table later on? I had to work on another programmer's project before, and he had used the same kind of insert style that you're using. It was a nightmare. INSERT INTO fifa09_stats VALUES ('$user', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0') INSERT INTO fifa09_stats (List of columns you're inserting into) VALUES(Corresponding values). Could help in a situation like this. Will also allow you to set the other columns as default 0 and only have to insert $user. Quote Link to comment Share on other sites More sharing options...
onthespot Posted August 15, 2009 Author Share Posted August 15, 2009 Hey cheers, I do know though that this can work, it did earlier in a different situation, so the SQL isn't the problem. I believe it's how I am running the queries? Quote Link to comment Share on other sites More sharing options...
waynew Posted August 15, 2009 Share Posted August 15, 2009 Ok - what do you see that you shouldn't be seeing? Quote Link to comment Share on other sites More sharing options...
onthespot Posted August 15, 2009 Author Share Posted August 15, 2009 What do you mean? The query that enters the users into the database works perfectly. But the 4 queries after dont seem to work? Quote Link to comment Share on other sites More sharing options...
waynew Posted August 15, 2009 Share Posted August 15, 2009 The first query isn't entering any users into the database? It's updating it? Quote Link to comment Share on other sites More sharing options...
onthespot Posted August 15, 2009 Author Share Posted August 15, 2009 ok sorry the first query WORKS though. I tried the following $stats1 = "INSERT INTO fifa09_stats (user, home_games_played, home_wins, home_draws, home_losses, home_goals_for, home_goals_against, home_points, away_games_played, away_wins, away_draws, away_losses, away_goals_for, away_goals_against, away_points) VALUES ('$user', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0')"; still didnt have any joy? Quote Link to comment Share on other sites More sharing options...
onthespot Posted August 15, 2009 Author Share Posted August 15, 2009 Solved, was linking to the activation php file wrong that was all, sorry for wasting your time Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.