Advertisement:

Author Topic: need little help changing this code to work with smf 2.0  (Read 11984 times)

Offline SA™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,953
  • (T)ogether (E)veryone (A)chieves (M)ore
    • DenotsNiaga on Facebook
    • SAChatBar
need little help changing this code to work with smf 2.0
« on: April 12, 2008, 03:15:40 AM »
cam somone please help me chang this to work with smf 2 i have tried but with no luck i got to the point where i am going to punch the crap out of my pc soon so fault ill ask here hope you can help thanks

wayne



Code: [Select]
function ArcadeStats_BestPlayers($count = 10)
{
global $db_prefix, $scripturl, $txt;
$res = $smcFunc['db_query']('', '
SELECT count(*) AS champions, IFNULL(mem.ID_MEMBER, 0) AS ID_MEMBER, IFNULL(mem.realName, '') AS realName, IFNULL(mem.avatar, '') AS avatar
FROM {$db_prefix}arcade_games AS game
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = game.ID_MEMBER_CHAMPION)
WHERE ID_CHAMPION_SCORE > 0
GROUP BY game.ID_MEMBER_CHAMPION
ORDER BY champions DESC 
LIMIT 0',$count", __FILE__, __LINE__);

$top = array();
$max = -1;

while ($score =$smcFunc['db_fetch_assoc']($res))


{
if ($max == -1)
$max = $score['champions'];

$top[] = array(
'name' => $score['realName'],
'avatar' => $score['avatar'],
'link' => !empty($score['realName']) ? '<a href="' . $scripturl . '?action=profile;u=' . $score['ID_MEMBER'] . '">' .  $score['realName'] . '</a>' : $txt['arcade_guest'],
'champions' => $score['champions'],
'precent' => ($score['champions'] / $max) * 100,
);
}

if (count($top) == 0)
return false;
elseif ($count > 1)
return $top;
else
return $top[0];
}
$top_player = ArcadeStats_BestPlayers(10);
$i=0; //players position

//array for icons
$poz = array('/first.gif','/second.gif','/third.gif','/fourth.gif','/fifth.gif','/sixth.gif','/seventh.gif','/eigth.gif','/ninth.gif','/tenth.gif');

echo '
<table width="100%" border="0" cellpadding="1">
<tr>
<td class="titlebg" colspan="10"><div align="center"><b>Top 10 Arcade Champions</b></div></td></tr><tr></br></tr><tr>';
foreach ($top_player as $row)
{
echo '

<td><div align="center"><img src="http://waynesworld.kicks-ass.net/forum/Themes/BlackRainv11/images/arc_icons',$poz[$i] , '"/><br/><br/>
<img src="avatars/', $row['avatar'],'"><br/>
',$row['link'],'<br/>
',$row['champions'],' </div></span></td>
';
$i++;
}

echo'</tr><tr></br></tr><tr></br></tr><tr></br></tr><tr></br></tr></table></div>';

     

edit ok i been fidling a bit more and got this far and get this error
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\*******\htdocs\champs.php on line 18
« Last Edit: April 21, 2008, 12:32:57 AM by joyrider »
http://samods.github.io/SAChatBar/

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

Offline karlbenson

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 15,630
  • Gender: Male
    • Lifeproof
Re: need little help changing this code to work with smf 2.0
« Reply #1 on: April 12, 2008, 12:34:50 PM »
I suspect its failing on
IFNULL(mem.realName, '')

You can't use single quotes inside the query.

Offline SA™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,953
  • (T)ogether (E)veryone (A)chieves (M)ore
    • DenotsNiaga on Facebook
    • SAChatBar
Re: need little help changing this code to work with smf 2.0
« Reply #2 on: April 12, 2008, 04:53:48 PM »
sry im still learning about mysql and stuff so how would i do it?
http://samods.github.io/SAChatBar/

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

Offline SleePy

  • Let there be light!
  • Site Team Lead
  • SMF Master
  • *
  • Posts: 30,859
  • Gender: Male
  • Thats his happy face.
    • jdarwood007 on GitHub
    • @jdarwood on Twitter
    • SleePy Code - My personal site
Re: need little help changing this code to work with smf 2.0
« Reply #3 on: April 12, 2008, 05:01:17 PM »
You would need to change that to use double quotes

Code: [Select]
IFNULL(mem.realName, "")
The same would apply for the avatar.

As well as the other quotes.

Where did you get the original from?

http://www.simplemachines.org/community/index.php?topic=224166.0
Jeremy D — Site Team / SMF Developer
Support the SMF Support team!
Profiles:
GitHub

Offline SA™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,953
  • (T)ogether (E)veryone (A)chieves (M)ore
    • DenotsNiaga on Facebook
    • SAChatBar
Re: need little help changing this code to work with smf 2.0
« Reply #4 on: April 12, 2008, 05:07:22 PM »
yes i got the origanal from there ill try that and see what happens thanks
http://samods.github.io/SAChatBar/

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

Offline SA™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,953
  • (T)ogether (E)veryone (A)chieves (M)ore
    • DenotsNiaga on Facebook
    • SAChatBar
Re: need little help changing this code to work with smf 2.0
« Reply #5 on: April 12, 2008, 05:10:34 PM »
ok done that now i get this

Parse error: syntax error, unexpected '"' in C:\******\htdocs\champs.php on line 24


edit i changed this

Code: [Select]
LIMIT 0',$count", __FILE__, __LINE__);
to

Code: [Select]
LIMIT 0',$count, __FILE__, __LINE__);
now i get

Fatal error: Function name must be a string in C:\******\htdocs\champs.php on line 17
 

« Last Edit: April 12, 2008, 05:13:34 PM by joyrider »
http://samods.github.io/SAChatBar/

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

Offline SA™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,953
  • (T)ogether (E)veryone (A)chieves (M)ore
    • DenotsNiaga on Facebook
    • SAChatBar
Re: need little help changing this code to work with smf 2.0
« Reply #6 on: April 14, 2008, 12:54:26 AM »
bump changed the code again globld it and now i het this


Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in C:\*******\htdocs\forum\Sources\Subs-Db-mysql.php on line 418

Warning: mysql_errno(): supplied argument is not a valid MySQL-Link resource in C:\*******\htdocs\forum\Sources\Subs-Db-mysql.php on line 419

Database Error

File: C:\******\htdocs\champs.php
Line: 25 


line 25 is this 

   LIMIT 0',$count, __FILE__, __LINE__);

please somone help thanks



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

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

Offline Bulakbol

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,220
  • Gender: Male
  • JohnyB
Re: need little help changing this code to work with smf 2.0
« Reply #7 on: April 14, 2008, 01:09:44 AM »
It looks like the original is from an arcade mod. Maybe better to ask the author of the mod.
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Offline SA™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,953
  • (T)ogether (E)veryone (A)chieves (M)ore
    • DenotsNiaga on Facebook
    • SAChatBar
Re: need little help changing this code to work with smf 2.0
« Reply #8 on: April 14, 2008, 02:28:51 AM »
no the code has nothing to do with the auther so i dont see how that will help
the code works fine with the arcade it was upuntill i upgraded what i want is for somone to help me update it to work with smf 2.0 i iknow for a fact that it works with e arcade 2.5.0 just not smf 2.0 as it worked well with 1.1.4

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

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

Offline SA™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,953
  • (T)ogether (E)veryone (A)chieves (M)ore
    • DenotsNiaga on Facebook
    • SAChatBar
Re: need little help changing this code to work with smf 2.0
« Reply #9 on: April 14, 2008, 02:07:14 PM »
i give up seen as nobody wants to help  :(
http://samods.github.io/SAChatBar/

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

Offline Bulakbol

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,220
  • Gender: Male
  • JohnyB
Re: need little help changing this code to work with smf 2.0
« Reply #10 on: April 15, 2008, 01:01:23 AM »
The mod you are trying to install is for 1.1.4. It has to be updated to work with 2.0 that's why you have to ask the author to update it.
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Offline SA™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,953
  • (T)ogether (E)veryone (A)chieves (M)ore
    • DenotsNiaga on Facebook
    • SAChatBar
Re: need little help changing this code to work with smf 2.0
« Reply #11 on: April 15, 2008, 01:26:16 AM »
what im not installing nothing lol its a script thats all not no mod al i wanted is for it to be updated to work with smf 2.0 no mods involved any way ive seeked help from another forum that actuly helped me and not confuse me like you have done to me
http://samods.github.io/SAChatBar/

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

Offline Bulakbol

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,220
  • Gender: Male
  • JohnyB
Re: need little help changing this code to work with smf 2.0
« Reply #12 on: April 15, 2008, 01:38:38 AM »
Sorry, I didn't mean to. Glad to know you found help from other site. Good luck.
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Offline metallica48423

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,842
  • Gender: Male
  • Professional Multislacker!
    • Zentendo
Re: need little help changing this code to work with smf 2.0
« Reply #13 on: April 17, 2008, 08:42:14 PM »
There is no need to be rude, Johny was simply trying to help.

So you were able to correct the issue?

There are other parts of that query that would need to be updated to work with 2.0's database structure, as well as the actual query itself.  If you still require assistance with that, please let us know
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

Quote
Microsoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"

Useful Links:
Online Manual!
How to Help us Help you   
Search
Settings Repair Tool
     

Offline Bulakbol

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,220
  • Gender: Male
  • JohnyB
Re: need little help changing this code to work with smf 2.0
« Reply #14 on: April 18, 2008, 06:24:51 AM »
 Thanks Metallica48423. I remember seeing the function from ArcadeStats.php so I thought it's the author's responsibility to update his/her mod.
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Offline SA™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,953
  • (T)ogether (E)veryone (A)chieves (M)ore
    • DenotsNiaga on Facebook
    • SAChatBar
Re: need little help changing this code to work with smf 2.0
« Reply #15 on: April 19, 2008, 04:12:03 AM »
There is no need to be rude, Johny was simply trying to help.

So you were able to correct the issue?

There are other parts of that query that would need to be updated to work with 2.0's database structure, as well as the actual query itself.  If you still require assistance with that, please let us know

i wasnt being rude and im sry if i come accrosse that way im just fed up with asking for support and people dont read my question properly and get me confused as i stated befor this works with the latest arcade i just needed the db_query changed and mysql fect assoc as i can do it i get error so if some one can do ill will be a happy bunny there simple no mods involved and certqainly no auther needed apart from smf with help to change the mentiond above

here is my code

Code: [Select]
function ArcadeStats_BestPlayers($count = 10)
{
global $smcFunc;

$results = db_query("'
SELECT count(*) AS champions, IFNULL(mem.ID_MEMBER, 0) AS ID_MEMBER, IFNULL(mem.realName, '') AS realName, IFNULL(mem.avatar, '') AS avatar
FROM {$db_prefix}arcade_games AS game
LEFT JOIN {$db_prefix}members AS mem ON (mem.id_member = game.id_member_first)
WHERE id_score_first > 0
GROUP BY game.id_member_first
ORDER BY champions DESC 
LIMIT 0,$count", __FILE__, __LINE__);

$top = array();
$max = -1;

while ($score = mysql_fetch_assoc($results))
{
if ($max == -1)
$max = $score['champions'];

$top[] = array(
'name' => $score['member_name'],
'avatar' => $score['avatar'],
'link' => !empty($score['member_name']) ? '<a href="' . $scripturl . '?action=profile;u=' . $score['id_member'] . '">' .  $score['member_name'] . '</a>' : $txt['arcade_guest'],
'champions' => $score['champions'],
//'precent' => ($score['champions'] / $max) * 100,
);
}

if (count($top) == 0)
return false;
elseif ($count > 1)
return $top;
else
return $top[0];
}
$top_player = ArcadeStats_BestPlayers(10);
$i=0; //players position

//array for icons
$poz = array('/first.gif','/second.gif','/third.gif','/fourth.gif','/fifth.gif','/sixth.gif','/seventh.gif','/eigth.gif','/ninth.gif','/tenth.gif');

echo '
<table width="100%" border="0" cellpadding="1">
<tr>
<td class="titlebg" colspan="10"><div align="center"><b>Top 10 Arcade Champions</b></div></td></tr><tr></br></tr><tr>';
if($top_player != false)
{
foreach ($top_player as $row)

echo '

<td><div align="center"><img src="http://waynesworld.kicks-ass.net/forum/Themes/default/images/arc_icons',$poz[$i] , '"/><br/><br/>
<img src="http://waynesworld.kicks-ass.net/forum/avatars/', $row['avatar'],'"><br/>
',$row['link'],'<br/>
',$row['champions'],' </div></span></td>
';
$i++;
}

echo'</tr><tr></br></tr><tr></br></tr><tr></br></tr><tr></br></tr></table></div>';[code]

this is the error i get when i change

$results = db_query("'

to

 $result = $smcFunc['db_query']('', '

and

while ($score = mysql_fetch_assoc($results))

to

while ($score = $smcFunc['db_fetch_assoc']($request))   

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\****\htdocs\champs.php on line 19

   
« Last Edit: April 19, 2008, 04:20:24 AM by joyrider »
http://samods.github.io/SAChatBar/

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

Offline metallica48423

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,842
  • Gender: Male
  • Professional Multislacker!
    • Zentendo
Re: need little help changing this code to work with smf 2.0
« Reply #16 on: April 19, 2008, 05:01:01 AM »
i'll have a look at it tomorrow -- part of it is going to need to be rewritten

*marks as unread*
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

Quote
Microsoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"

Useful Links:
Online Manual!
How to Help us Help you   
Search
Settings Repair Tool
     

Offline SA™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,953
  • (T)ogether (E)veryone (A)chieves (M)ore
    • DenotsNiaga on Facebook
    • SAChatBar
Re: need little help changing this code to work with smf 2.0
« Reply #17 on: April 19, 2008, 05:11:35 AM »
ok thanks i do appretiate it im getting to the point where im getting so stressed over but i dont like just giving up
http://samods.github.io/SAChatBar/

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

Offline metallica48423

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,842
  • Gender: Male
  • Professional Multislacker!
    • Zentendo
Re: need little help changing this code to work with smf 2.0
« Reply #18 on: April 20, 2008, 06:06:27 PM »
Alright: give this a try:

Code: [Select]
<?php

function ArcadeStats_BestPlayers($count 10)
{
global 
$smcFunc;

$result $smcFunc['db_query'](''"
SELECT count(*) AS champions, IFNULL(mem.ID_MEMBER, 0) AS ID_MEMBER, IFNULL(mem.realName, '') AS realName, IFNULL(mem.avatar, '') AS avatar
FROM {db_prefix}arcade_games AS game
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = game.id_member_first)
WHERE id_score_first > 0
GROUP BY game.id_member_first
ORDER BY champions DESC 
LIMIT 0, {int:count}"
,
array(
'count' => $count,
)
 );

$top = array();
$max = -1;

while (
$score $smcFunc['db_fetch_assoc']($result))
{
if (
$max == -1)
$max $score['champions'];

$top[] = array(
'name' => $score['member_name'],
'avatar' => $score['avatar'],
'link' => !empty($score['member_name']) ? '<a href="' $scripturl '?action=profile;u=' $score['id_member'] . '">' .  $score['member_name'] . '</a>' $txt['arcade_guest'],
'champions' => $score['champions'],
//'precent' => ($score['champions'] / $max) * 100,
);
}

if (
count($top) == 0)
return 
false;
elseif (
$count 1)
return 
$top;
else
return 
$top[0];
}
$top_player ArcadeStats_BestPlayers(10);
$i=0//players position

//array for icons
$poz = array('/first.gif','/second.gif','/third.gif','/fourth.gif','/fifth.gif','/sixth.gif','/seventh.gif','/eigth.gif','/ninth.gif','/tenth.gif');

echo 
'
<table width="100%" border="0" cellpadding="1">
<tr>
<td class="titlebg" colspan="10"><div align="center"><b>Top 10 Arcade Champions</b></div></td></tr><tr></br></tr><tr>'
;
if(
$top_player != false)
{
foreach (
$top_player as $row)

echo 
'

<td><div align="center"><img src="http://waynesworld.kicks-ass.net/forum/Themes/default/images/arc_icons'
,$poz[$i] , '"/><br/><br/>
<img src="http://waynesworld.kicks-ass.net/forum/avatars/'
$row['avatar'],'"><br/>
'
,$row['link'],'<br/>
'
,$row['champions'],' </div></span></td>
'
;
$i++;
}

echo
'</tr><tr></br></tr><tr></br></tr><tr></br></tr><tr></br></tr></table></div>';

?>

Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

Quote
Microsoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"

Useful Links:
Online Manual!
How to Help us Help you   
Search
Settings Repair Tool
     

Offline SA™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,953
  • (T)ogether (E)veryone (A)chieves (M)ore
    • DenotsNiaga on Facebook
    • SAChatBar
Re: need little help changing this code to work with smf 2.0
« Reply #19 on: April 20, 2008, 06:12:34 PM »
that gives this error

Database Error
Please try again. If you come back to this error screen, report the error to an administrator


thanks for for helping me
http://samods.github.io/SAChatBar/

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