Jump to content

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/165336-hey-guys-i-am-having-an-if-problem/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.