Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Fetch variable not working as anticipated
Old 07-21-2010, 11:34 PM Fetch variable not working as anticipated
Skilled Talker

Posts: 83
Trades: 0
In my code, I loop through 3 random users, and I am trying to add 500 to their total number of credits. The variable $credits isn't being captured correctly, as it shows blank when I try to echo it. The odd part however, is $userid (primary key) is captured into the variable. What do I need to modify in my code to fix this issue?
Or, perhaps is there a way to just add 500 to the current total of credits by using the mysql update?


PHP Code:
<?php

include_once('../inc/connect.php');

$date date("Y-m-d");

$drawquery mysql_query("SELECT id FROM userstats WHERE `todaysurfed`>=250 AND DATEDIFF(NOW(),`wondaily`) > 30 OR `wondaily`='0000-00-00' ORDER BY rand() LIMIT 3");

while(
$row mysql_fetch_array($drawquery))
  {

$userid $row['id'];
$credits $row['credits'];
$addcredits 500;
$newcredits $credits $addcredits;

echo 
$userid."<br />";

$updatewinners mysql_query("UPDATE userstats SET wondaily='$date', credits='$newcredits' WHERE id='$userid'");

}

?>

Thanks
Smudly is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-22-2010, 02:32 AM Re: Fetch variable not working as anticipated
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Code:
SELECT id FROM userstats
You aren't selecting the credits column in your query. Try:
Code:
SELECT id, credits FROM userstats
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Reply     « Reply to Fetch variable not working as anticipated
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23910 seconds with 12 queries