PDA

View Full Version : [mysql]Easy Question


pyro.699
11-15-2005, 08:41 PM
ok, im making this script, and i thought it was an awesome idea! What it dose, is when ever a user clicks on one of those 'Vote for Us' or 'Top 100' buttons, it first takes them to my script, ad.php, once they click, they are given a random number ( 100-1000 ) points.

heres what i have so far, with the proper crap blocked :P


<?php
// ### vBulletin Shit ### \\
error_reporting(E_ALL & ~E_NOTICE);
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'portal');
$phrasegroups = array();
$specialtemplates = array();
$globaltemplates = array();
$actiontemplates = array();
require_once('./global.php');
require_once('./includes/functions_bigthree.php');
require_once('./includes/functions_forumlist.php');
require_once('./includes/class_bbcode.php');
//############################################\\

// Generate the random Number!
srand(time());
$points_add = (rand()%900) + 100;

$current_points = $db->query_first("SELECT ucash FROM ". TABLE_PREFIX ."user WHERE userid = 1");;

$new_total_points = $points_add + $current_points;

// **************
if ($_GET['refer'] == '*****_***_***')
{
//Run Query
$db->query_write(
"UPDATE ". TABLE_PREFIX ."user
ucash = ".$new_total_points."
where userid = '" . $vbulletin->userinfo['userid'] . "'");
//Forward
$vbulletin->url = "**************************";
eval(print_standard_redirect("You have just recieved more $points_add points", false, true));
}

//*************
if ($_GET['refer'] == '***_****_*****)
{

//Forward
$vbulletin->url = "*************";
eval(print_standard_redirect("You have just recieved more $points_add points", false, true));
}

//*********
if ($_GET['refer'] == '*****_*****')
{

//Forward
$vbulletin->url = "***************";
eval(print_standard_redirect("You have just recieved more $points_add points", false, true));
}

?>


now, my problem lies with $current_points and $new_total_points

I have tryed putting a echo $current_points but, all i get is the word, array

now, with $new_total_points, is it correct? because i tryed adding numbers instaead of variables, and it still dident work!

So, what am i missing, and what do i need?

Thanks!

Paul M
11-15-2005, 08:46 PM
$current_points is an array of what you read from the SQL query. The value you want will be in $current_points['ucash']

pyro.699
11-15-2005, 08:48 PM
hey, you finally got your title ;)


replace, $current_points with $current_points['ucash']