[Tool]PHP/HTML Top 100 list small error

Have you created a useful tool? or Do you want to get help building one? This is the right place!
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
laxsur
Posts: 85
Joined: Thu Jul 25, 2013 10:22 pm

[Tool]PHP/HTML Top 100 list small error

Post 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
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

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

Post 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
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
laxsur
Posts: 85
Joined: Thu Jul 25, 2013 10:22 pm

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

Post 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
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

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

Post 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?
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
laxsur
Posts: 85
Joined: Thu Jul 25, 2013 10:22 pm

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

Post 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.
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

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

Post 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?
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
laxsur
Posts: 85
Joined: Thu Jul 25, 2013 10:22 pm

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

Post 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>
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

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

Post 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.
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
laxsur
Posts: 85
Joined: Thu Jul 25, 2013 10:22 pm

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

Post by laxsur »

Fatal error: Cannot pass parameter 2

Code: Select all

$pstmt->bind_param('ii', 0, 100); // ii - integer, integer
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

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

Post 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
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
laxsur
Posts: 85
Joined: Thu Jul 25, 2013 10:22 pm

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

Post by laxsur »

perfect
now appears Offline shop
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

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

Post by jurchiks »

You better work on polishing your HTML/PHP skills now. The previous script was really badly written.
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
laxsur
Posts: 85
Joined: Thu Jul 25, 2013 10:22 pm

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

Post by laxsur »

one last question
I wanted two files in order to have your passwords in a secure folder
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

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

Post 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.
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
laxsur
Posts: 85
Joined: Thu Jul 25, 2013 10:22 pm

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

Post by laxsur »

all sorted thanks
Post Reply