maltech Posted July 9, 2009 Share Posted July 9, 2009 First of all everything else is working fine. Yes I am learning, I am doing this project to learn, and it is fun to me to learn new things. All of your help and advice is greatly appreciated! Now here is the code I am trying to use: // Load User into Database if they do not exist mysql_query("INSERT INTO Usertable (userid, name) VALUES ('$user_id', '<fb:name uid=\"$user_id\" useyou=\"false\" />')"); // Query the Usertable for Information $query = "SELECT * FROM Usertable WHERE userid = '$user_id'"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo '<div id="stats">'; echo "Thanks for Stoping By {$row['name']} "; // If they have no value in level add level 1 to the Usertable if (empty($row['level'])) { mysql_query("INSERT INTO Usertable (level) VALUES ('1')"); } echo "<br>"; echo "Your Level Is {$row['level']} "; echo '</div>'; } // Close the Database mysql_close(); The problem I am having it it seems the level is not being set to 1 or anything else for that matter, because this is my output on the page: Thanks for Stoping By Chuck Cagle Your Level Is Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/165336-hey-guys-i-am-having-an-if-problem/ Share on other sites More sharing options...
maltech Posted July 9, 2009 Author Share Posted July 9, 2009 OK After slapping myself and drinking coffee I found the solution. Thank you to everyone who was attempting to come up with one for me, As always I appreciate any help even if its not seen. This was the solution: if (empty($row['level'])) { mysql_query("UPDATE Usertable SET level = '1' WHERE userid = '$user_id'"); } I was trying to set a new row instead of update the existing one. Quote Link to comment https://forums.phpfreaks.com/topic/165336-hey-guys-i-am-having-an-if-problem/#findComment-871916 Share on other sites More sharing options...
Maq Posted July 9, 2009 Share Posted July 9, 2009 If your question has been resolved, please signify that by clicking 'Topic Solved' in the bottom left. Quote Link to comment https://forums.phpfreaks.com/topic/165336-hey-guys-i-am-having-an-if-problem/#findComment-871928 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.