Jump to content

Recommended Posts

mysql_query is a resource. You must fetch the data using mysql_fetch_array/mysql_fetch_assoc/mysql_fetch_row (although I don't recommend using the latter of the three.

Gayner is running an UPDATE statement which doesn't return any results. So these functions will not serve any purpose.

 

<?php
function test(){
mysql_query("UPDATE ibf_members SET points = points+0.25 WHERE id={$ibforums->member["id"]} LIMIT 1");
}
?>

 

case 3: content='You won this round. <?php echo test(); ?>';

 

It doesn'tw ork? whY?

What are expecting to be returned from your test() function? What are you trying to do. Functions do not return anything unless you tell it to.

mysql_query is a resource. You must fetch the data using mysql_fetch_array/mysql_fetch_assoc/mysql_fetch_row (although I don't recommend using the latter of the three.

Gayner is running an UPDATE statement which doesn't return any results. So these functions will not serve any purpose.

 

<?php
function test(){
mysql_query("UPDATE ibf_members SET points = points+0.25 WHERE id={$ibforums->member["id"]} LIMIT 1");
}
?>

 

case 3: content='You won this round. <?php echo test(); ?>';

 

It doesn'tw ork? whY?

What are expecting to be returned from your test() function? What are you trying to do. Functions do not return anything unless you tell i

t to.

 

Can u tell me how to make it return that query? lol thanks

UPDATE queries do not return any results. However you can use the function called mysql_affected_rows which returns the number of rows your query affected.

 

For a fuctuion to return any thing you need to use the return keyword. As explained in the manual.

 

 

Update queries don't return anything, as previously stated.

 

 

What data are you trying to get?

 

Not trying to get any data, just update..

 

 

 

That case 3 is run from:

 

if(isplayer){
playerwins[level]++;
playerstarts=true;
writetext(3);
}else{/code]

it's a Tic tac toe script..

I want that user to get points+0.25 each time they win tic tac to game, it's javascript based.. im triyn to implent php to it

:o

 

...I don't know how I didn't catch that.

 

Anyway, I suppose he could be trying to use mysql_affected_rows or mysql_info?

Just a stab in the dark.

 

Warning - while you were typing a new reply has been posted. You may wish to review your post.

 

You could use something like this:

 

<?php
function test(){
    global $sql;
    $sql = "UPDATE ibf_members SET points = points+0.25 WHERE id={$ibforums->member["id"]} LIMIT 1";
    mysql_query($sql);
}
?>

case 3: content='You won this round. <?php echo $sql; ?>';

function test(){
$sql = "UPDATE ibf_members SET points = points+0.25 WHERE id={$ibforums->member["id"]} LIMIT 1";
return $sql;
}

 

I did this and then i did

case 3: content='You won this round. <?php echo test(); ?>';

 

but it spits it out as text?

 

 

 

You won this round. UPDATE ibf_members SET points = points+0.25 WHERE id= LIMIT 1

 

??

OK i changed it to:

 

<?php
function test(){
$sql = mysql_query("UPDATE ibf_members SET points = points+0.25 WHERE id={$ibforums->member["id"]} LIMIT 1");
return $sql;
}
?>

 

Now when I win my tic tac toe game it doesn't spit it out as text, but it doesnt run, lol :(

 

HMM ???

...wow.

 

<?php
function test(){
    $sql = "UPDATE `ibf_members` SET `points` = points+0.25 WHERE id='" . $ibforums->member['id'] . "' LIMIT 1";
    mysql_query($sql);
    return $sql;
}
?>

 

Like I said bro that spit's out plain text...

 

My way doesn't split out plain text so i know it's closer then worker then urs sorry :)

Your function doesnt display anything as mysql_query does not return anything! However the query is running, provided you have connection to mysql first of course.

 

Hold on I just noticed something your function should actually be

<?php
function test($memberID)
{
   return mysql_query("UPDATE ibf_members SET points = points+0.25 WHERE id={$memberID} LIMIT 1");
}

if(test($ibforums->member["id"]))
{
     echo 'You won this round';
}
else
{
     echo 'Error! unable to update player points! For member id - '. $ibforums->member["id"];
}

?>

 

Your function doesnt display anything as mysql_query does not return anything! However the query is running, provided you have connection to mysql first of course.

 

Hold on I just noticed something your function should actually be

<?php
function test($memberID)
{
   return mysql_query("UPDATE ibf_members SET points = points+0.25 WHERE id={$memberID} LIMIT 1");
}

if(test($ibforums->member["id"]))
{
     echo 'You won this round';
}
else
{
     echo 'Error! unable to update player points! For member id - '. $ibforums->member["id"];
}

?>

 

LOL Sir, i have included a full SDK..

 

<?php
// Load and Start IPB SDK
require_once "ipbsdk/ipbsdk_class.inc.php";
$SDK =& new IPBSDK();
global $ibforums, $DB;
?>

 

This is were all my functions ipbsdk_class.inc is over 100kilobytes big it has everything i need in there,

 

I can use global functions like

{$ibforums->member["id"]}

for my username id etc.. or any row from database, lol

 

And the query works if it doesn't get called from a function or from this javascript:

 

 

case 3: content='You won this round. <?php echo test(); ?>';

That ^^ function is called from:

 

if(iswon){
if(isplayer){
playerwins[level]++;
playerstarts=true;
writetext(3);
}else{
pcwins[level]++;
playerstarts=false;
writetext(2);
}}

 

Writetext(3) see

haha, I was just writing a function to do the same thing wildteen88.

 

function test($id) {
$query = mysql_query("UPDATE ibf_members SET points = points+0.25 WHERE id=" . $id . " LIMIT 1");
if($query) {
	 print('You won this round');
} else {
	print('MySQL has encountered an error: ' . mysql_error());
}
}

 

And then use this in the page:

 

case 3: content='You won this round. <?php echo test(); ?>';

(Just like the code you used before)

 

Warning - while you were typing a new reply has been posted. You may wish to review your post.

 

Wait, what about your SDK?

:confused:

haha, I was just writing a function to do the same thing wildteen88.

 

function test($id) {
$query = mysql_query("UPDATE ibf_members SET points = points+0.25 WHERE id=" . $id . " LIMIT 1");
if($query) {
	 print('You won this round');
} else {
	print('MySQL has encountered an error: ' . mysql_error());
}
}

 

And then use this in the page:

 

case 3: content='You won this round. <?php echo test(); ?>';

(Just like the code you used before)

 

Warning - while you were typing a new reply has been posted. You may wish to review your post.

 

Wait, what about your SDK?

:confused:

 

were u getting $id from? lol

Just use this script, okay?

 

function query($id) {
$query = mysql_query("UPDATE ibf_members SET points = points+0.25 WHERE id=" . $id . " LIMIT 1");
if($query) {
	 print('You won this round.');
} else {
	print('MySQL has encountered an error: ' . mysql_error());
}
}

 

case 3: content='You won this round. <?php print(query($ibforums->member['id'])); ?>';

Just use this script, okay?

 

function query($id) {
$query = mysql_query("UPDATE ibf_members SET points = points+0.25 WHERE id=" . $id . " LIMIT 1");
if($query) {
	 print('You won this round.');
} else {
	print('MySQL has encountered an error: ' . mysql_error());
}
}

 

case 3: content='You won this round. <?php print(query($ibforums->member['id'])); ?>';

 

It wont work because $id is not found.. anywere

 

EDIT: I saw ur edit sec

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.