News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

need little help changing this code to work with smf 2.0

Started by SA™, April 12, 2008, 03:15:40 AM

Previous topic - Next topic

SA™

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




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
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 -___-

karlbenson

I suspect its failing on
IFNULL(mem.realName, '')

You can't use single quotes inside the query.

SA™

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
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

SleePy

You would need to change that to use double quotes

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 ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

SA™

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
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

SA™

ok done that now i get this

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


edit i changed this

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

to

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

now i get

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


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™

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
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Bulakbol

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

SA™

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
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

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 -___-

Bulakbol

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

SA™

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
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Bulakbol

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

metallica48423

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

QuoteMicrosoft 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

Bulakbol

 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

SA™

#15
Quote from: metallica48423 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

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

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

   
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 -___-

metallica48423

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

QuoteMicrosoft 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

SA™

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
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

metallica48423

Alright: give this a try:


<?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

QuoteMicrosoft 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

SA™

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
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Advertisement: