News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

im stumped sub actions

Started by SA™, May 31, 2008, 12:26:40 AM

Previous topic - Next topic

SA™

nope get this error

Parse error: syntax error, unexpected T_ELSE in C:\xampp\htdocs\test\Sources\multiplayer.php on line 26
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Dragooon

Actually, I just realized the error, you had 4 else after 1 if.
It should be something like
<?php
function multiplayer() {

global $context;
if (!defined('SMF'))
   die('Hacking attempt...');
  // Do we have permission?
   isAllowedTo('multiplayer_view'); 
//load the template
   loadTemplate('multiplayer');

if($_REQUEST['sa']=="Poker")
{
// Do we have permission?
   isAllowedTo('multiplayer_play');
   //load up the games 
$context['sub_template'] = 'Texas_Hold_em_Poker_Multiplayer';
}
elseif($_REQUEST['sa'] == 'Chess')
{
// Do we have permission?
   isAllowedTo('multiplayer_play');
   //load up the games 
$context['sub_template'] = 'Chess_Multiplayer';
}
elseif($_REQUEST['sa'] == 'Conquer_Antartica')
{
// Do we have permission?
   isAllowedTo('multiplayer_play');
   //load up the games 
$context['sub_template'] = 'Conquer_Antarctica_Multiplayer';
}
else
{
// Do we have permission?
   isAllowedTo('multiplayer_play');
   //load up the games 
$context['sub_template'] = 'Bunny_Wars_Multiplayer';
}
}
?>

SA™

http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

SA™

how to set this

QuoteYou should ensure that $_REQUEST['sa'] is set before using this. Otherwise this will cause an undefined index errors on page loads.
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Dragooon

After the function starts you can add
$_REQUEST['sa'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : '';

SA™

thank you so much i appretiate it
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

SA™

how hard would it be to code a simple script to count the clicks when the games are clicked

but i want it so it count each link seprate



hope you understand what i mean

wayne
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

[SiNaN]

Add a field to the database and increase the value there by adding the db query to each subaction.
Former SMF Core Developer | My Mods | SimplePortal

SA™

can you show me an example please for smf 2.0
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Nathaniel

#29
Some code like this would probably work, assuming that you have created a table called "{db_prefix}clickcounts", with the fields 'name' and 'count'.

To update:


        global $smcFunc;

        // Run the query.
$request = $smcFunc['db_query']('', '
SELECT name, count
FROM {db_prefix}clickcounts'
);

        // Get the actual data.
while ($row = $smcFunc['db_fetch_assoc']($request))
$clickcount_data[$row['name']] = $row['count'];

// Don't forget to free the request!!!
$smcFunc['db_free_result']($request);

        $new_count = $clickcount_data[$current_name]+1;

               // Run the query.
$smcFunc['db_query']('', '
UPDATE {db_prefix}clickcounts
                SET count = ' . $new_count .'
                WHERE name = ' . $current_name
);



That may have some errors, but you get the general idea. Sorry about the tabbing, it mucked up for some reason. :(
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

SA™

ok i dont have the table in the database

would this one work

$smcFunc['db_query']('', '("INSERT INTO {$db_prefix}clickcounts (`variable`,`value`) VALUES('clickcounts','0')",__FILE__,__LINE__);

or is it wrong
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

[SiNaN]

Example:

smf_clickcounts

name value
chess 0
football 0

This should be the default.

Then in your codes:

In chess function:

db_query("UPDATE {$db_prefix}clickcounts
SET value = value + 1
WHERE name = 'chess'
LIMIT 1", __FILE__, __LINE__);


In football function:

db_query("UPDATE {$db_prefix}clickcounts
SET value = value + 1
WHERE name = 'football'
LIMIT 1", __FILE__, __LINE__);
Former SMF Core Developer | My Mods | SimplePortal

SA™

hmm im lost what query do i have to run in phpmyadmin to make the table
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

[SiNaN]

CREATE TABLE smf_clickcounts (
  name text NOT NULL,
  value tinyint(8) NOT NULL default 0
)
Former SMF Core Developer | My Mods | SimplePortal

Nathaniel

#34
~[SiNaN]: Remember that SMF 2 Beta doesn't use the db_query function anymore,  database functions change dramatically between SMF 1.1.5 and SMF 2 Beta.

~wdm2005
You should be able to add a table to the database in phpmyadmin at the bottom of the page which lists all of the tables in the database. You can also create it in the operations tab.

Then in the table's structure area you can add the necessary fields. Remember that you shouldn't actually need to run the sql queries yourself for setting up the structure because phpmyadmin can do it for you.
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

[SiNaN]

#35
LHVWB, I know that. Just I am not familiar with the db function in SMF 2.0.x. I gave the ones for 1.1.x, it must be adapted to the 2.0.x functions. But forgot to mention that.

//Edit:

Here is the code for the 2.0.x:

$smcFunc['db_query']('', '
UPDATE {$db_prefix}clickcounts
SET value = value + 1
WHERE name = chess
LIMIT 1');
Former SMF Core Developer | My Mods | SimplePortal

SA™

ok i made the table

added this code to my multiplayer .php

function clickcounts() {

db_query("UPDATE {$db_prefix}clickcounts
SET value = value + 1
WHERE name = ' Conquer Antarctica Multiplayer'
LIMIT 1", __FILE__, __LINE__);
}


then in multiplayer template i added this

<strong>' , $txt['PLYD'] , '</strong>';clickcounts(); echo '<br>

and get this

Database Error
Please try again. If you come back to this error screen, report the error to an administrator. 
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

SA™

the error log show that the table isnt there but it is ?
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Nathaniel

A few possible issues could be happening.

What did you name the table?

Try replacing '{$db_prefix}clickcounts' with the actual name of the table, you may not have put the smf prefix onto the beginning so this could be the issue.
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

SA™

that done the trick

but its not showing nothing

look here

http://waynesworld.kicks-ass.net/test/index.php?action=multiplayer

see where it says plays i want the number to show there
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Advertisement: