Jump to content

This Code Doesn't Work


robbins

Recommended Posts

i'm inserting this into a phpfusion page, so the dbconnect is done, and dbquery is how fusion does its sql querys... and also the $userdata part is fusions variable for the user, so all of that stuff works...  now heres the code, and my problem is below.

<?
$result = dbquery("select * from site_users where user_id=".$userdata['user_id']);
if ($result['js1'] == true) {
echo "ERROR: You've Already Done This!";
}
else {
$rr = dbquery('update '.$db_prefix.'users set js1=true where user_id='.$userdata['user_id'].' limit 1;');
$rrr = dbquery('update '.$db_prefix.'users set user_points=user_points+3 where user_id='.$userdata['user_id'].' limit 1;');
}
?>



i run it... and it set my user accounts js1 to true... but then, when i ran it again... it still ran whats under else ... even though my accounts js1 is set to true... what is up with that???
Link to comment
Share on other sites

That query will not return "True". It only returns false or a resource. And from that resource, before you do anything with it, you are trying to use it as an array.

[code]<?
$result = dbquery("select * from site_users where user_id=".$userdata['user_id']);
$row = mysql_fetch_array($result);
if ($row['Username'] == "js1" ) {
echo "ERROR: You've Already Done This!";
}
else {
$rr = dbquery('update '.$db_prefix.'users set js1=true where user_id='.$userdata['user_id'].' limit 1;');
$rrr = dbquery('update '.$db_prefix.'users set user_points=user_points+3 where user_id='.$userdata['user_id'].' limit 1;');
}
?>[/code]

I believe this will work. It may not, as I am still new to PHP.
Link to comment
Share on other sites

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.