Page 1 of 1

[Tool]PHP/HTML Top 100 list small error

Posted: Sat Jul 27, 2013 1:22 pm
by laxsur
File Name = script_config.php

Code: Select all

<?php     $db_user = "root";     $db_pass = "root";     $db_name = "l2jgs";     $db_serv = "localhost";      $res = mysql_connect ( $db_serv, $db_user, $db_pass ) or die ("Coudn't connect to [$db_serv]");     $resdb = mysql_select_db ( "$db_name",$res );      return $res;  ?>
File Name = top_100_list.php

Code: Select all

  <html><BODY BACKGROUND="bg.gif" BGCOLOR="#000000" TEXT="#FFFFFF"> <center><br><br><font size="+2"><b>Top 100</b></font><br><br><br><br><?php  function connect() { include "configs/script_config.php";} $sexes = array('M', 'F'); $online = array('0' => "<font color=#FF0000>Offline</font>", '1' => "<font color=#00FF00>Online</font>"); $FORM = "<table border='1'>  <tr> <th class='Stil5' align=center>Pos.</th> <th class='Stil5' align=center>Char.Name</th> <th class='Stil5' align=center>Level</th>  <th class='Stil5' align=center>Sex</th> <th class='Stil5' align=center>Clan</th> <th class='Stil5' align=center>Last Online</th><th class='Stil5' align=center>Status</th></tr>"; $query_chars = "select char_name,level,sex,clanid,lastAccess,online from characters WHERE accesslevel=0 order by exp desc limit 100;"; connect(); $link = mysql_query($query_chars); $i=1; $r=255; while ( $row=mysql_fetch_row($link) ) {     $timer2=$row[4]/1000;    $datetime2  = gmstrftime("%d.%m.%Y | %H:%M:%S", $timer2);    $query = "select clan_name from clan_data where clan_id=$row[3]";     $link2 = mysql_query($query);     $clan = mysql_fetch_row($link2);      $FORM .= "<tr>     <td class='Stil5' align=center>$i</span></td>     <td class='Stil5' align=center>$row[0]</td>     <td class='Stil5' align=center>$row[1]</td>      <td class='Stil5' align=center>".$sexes[$row[2]]."</td>      <td class='Stil5' align=center>[".$clan[0]."]</td>      <td class='Stil5' align=center>$datetime2</td>    <td class='Stil5' align=center>".$online[$row[5]]."</td>    </tr>";     $i++;     $r -= 0; }   mysql_close();  echo $FORM;  ?></center></body></html>
Effect
Image

When there are vendors saved on the server as offline, release this error
Image

you know how to remove this error when there are characters that gives offline

Re: [Tool]PHP/HTML Top 100 list small error

Posted: Sat Jul 27, 2013 2:27 pm
by jurchiks
Jesus people, stop using the deprecated mysql_* functions already, they fucking suck.
Not to mention that HTML design is terrible.

Try this: http://pastebin.com/W4MsT0SW

Re: [Tool]PHP/HTML Top 100 list small error

Posted: Sat Jul 27, 2013 3:36 pm
by laxsur
jurchiks wrote:Jesus people, stop using the deprecated mysql_* functions already, they fucking suck.
Not to mention that HTML design is terrible.

Try this: http://pastebin.com/W4MsT0SW


Problem is not solved
Image

now always error

Re: [Tool]PHP/HTML Top 100 list small error

Posted: Sat Jul 27, 2013 3:42 pm
by jurchiks
But what is the fucking actual error? Get the error log open, find the real problem, this gives me nothing.
Maybe your db credentials are invalid?

Re: [Tool]PHP/HTML Top 100 list small error

Posted: Sat Jul 27, 2013 3:57 pm
by laxsur
I do not understand what is the error in my code.
in my case the error appears when there are players to sell or buy offline.
if there are no players in offline work correctly.

Re: [Tool]PHP/HTML Top 100 list small error

Posted: Sat Jul 27, 2013 4:05 pm
by jurchiks
Dude, wtf? Do you even have access to your website's error log? You know, the one in /var/log/nginx/yourdomain-error.log or /var/log/apache2/yourdomain-error.log?

Re: [Tool]PHP/HTML Top 100 list small error

Posted: Sat Jul 27, 2013 8:04 pm
by laxsur
this is the part of code that error

Code: Select all

while ( $row=mysql_fetch_row($link) ) {     $timer2=$row[4]/1000;    $datetime2  = gmstrftime("%d.%m.%Y | %H:%M:%S", $timer2);    $query = "select clan_name from clan_data where clan_id=$row[3]";     $link2 = mysql_query($query);     $clan = mysql_fetch_row($link2);      $FORM .= "<tr>     <td class='Stil5' align=center>$i</span></td>     <td class='Stil5' align=center>$row[0]</td>     <td class='Stil5' align=center>$row[1]</td>      <td class='Stil5' align=center>".$sexes[$row[2]]."</td>      <td class='Stil5' align=center>[".$clan[0]."]</td>      <td class='Stil5' align=center>$datetime2</td>    <td class='Stil5' align=center>".@$online[$row[5]]."</td>    </tr>";     $i++;     $r -= 0; }  


block the error with the @$online

Code: Select all

<td class='Stil5' align=center>".@$online[$row[5]]."</td>

Re: [Tool]PHP/HTML Top 100 list small error

Posted: Sat Jul 27, 2013 8:12 pm
by jurchiks
Yeah, not helpful. Try my code and get access to your error log. I have accounted for offline traders.
Just change the dbname/login/password in the file.

Re: [Tool]PHP/HTML Top 100 list small error

Posted: Sat Jul 27, 2013 8:25 pm
by laxsur
Fatal error: Cannot pass parameter 2

Code: Select all

$pstmt->bind_param('ii', 0, 100); // ii - integer, integer

Re: [Tool]PHP/HTML Top 100 list small error

Posted: Sat Jul 27, 2013 8:29 pm
by jurchiks
Well that sucks...
Updated the paste, changed only this:

Code: Select all

$accessLevel = 0;$limit = 100;$pstmt->bind_param('ii', $accessLevel, $limit); // ii - integer, integer

Re: [Tool]PHP/HTML Top 100 list small error

Posted: Sat Jul 27, 2013 8:46 pm
by laxsur
perfect
now appears Offline shop

Re: [Tool]PHP/HTML Top 100 list small error

Posted: Sat Jul 27, 2013 8:50 pm
by jurchiks
You better work on polishing your HTML/PHP skills now. The previous script was really badly written.

Re: [Tool]PHP/HTML Top 100 list small error

Posted: Sat Jul 27, 2013 9:02 pm
by laxsur
one last question
I wanted two files in order to have your passwords in a secure folder

Re: [Tool]PHP/HTML Top 100 list small error

Posted: Sat Jul 27, 2013 9:27 pm
by jurchiks
Put this:

Code: Select all

$dbcon = new mysqli('host', 'username', 'password', 'database'); if (mysqli_connect_error()){        error_log('Failed to connect to the database. Error: [' . mysqli_connect_errno() . '] ' . mysqli_connect_error());        die();}
inside a different file and require it in this script. It's basic stuff.

Re: [Tool]PHP/HTML Top 100 list small error

Posted: Sat Jul 27, 2013 9:49 pm
by laxsur
all sorted thanks