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
https://forums.phpfreaks.com/topic/32257-this-code-doesnt-work/
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
https://forums.phpfreaks.com/topic/32257-this-code-doesnt-work/#findComment-149708
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.