Help with php
#1

Код:
This page isn’t working

*********.com is currently unable to handle this request.
HTTP ERROR 500
The code of the .php file:
PHP код:
<?php 
include 'includes/config.php'
include 
'includes/header.php';
checkForLogin();
if(!isset(
$_GET['id']))
{
    echo 
'<META HTTP-EQUIV="Refresh" Content="0; URL=../pages/index.php">';    
    exit;    
}
$charaID $_GET['id'];
$sesuID $_SESSION['uID'];
$query $con->prepare("SELECT * from players where reg_id = '$charaID'");
$query->execute();
$gData $query->fetch();
if(
$gData['reg_id'] != $sesuID)
{
    echo 
'<META HTTP-EQUIV="Refresh" Content="0; URL=../pages/index.php">';    
    exit;    
}
?>
                <div class="row">
                    <div class="col-md-12">
                        <h1 class="page-header">
                            <?php echo $gData['name']; ?>
                        </h1>
                    </div>
                </div>
            <div class="row">
                <div class="col-lg-2">
                    <img src="../skins/Skin_<?php echo $gData['saveskin']; ?>.png" style="height:300px;">
                </div>
                <div class="col-lg-8">
                    <div class="panel panel-default">
                        <div class="panel-body">
                            <div class="row">
                                <div class="col-lg-6">
                                Status: <?php if($gData['active'] == 1
                                            { 
                                                echo 
'<span style="color:#00FF00";>ONLINE</span>' 
                                            
}
                                            else
                                            {
                                                echo 
'<span style="color:#FF0000";>OFFLINE</span>'
                                            
?>
                                <hr />
                                Playing Time: <?php echo($gData['hours']); ?> Hours, <?php echo($gData['minutes']); ?> Minutes and <?php echo($gData['seconds']); ?> Seconds
                                <hr />
                                Premium: <?php if($gData['premium'] == 1)
                                            {
                                                echo 
'<span style="color:#00FF00";>PREMIUM</span>' 
                                            
}
                                            else if(
$gData['premium'] == 2)
                                            {
                                                echo 
'<span style="color:#00FF00";>PREMIUM 2</span>' 
                                            
}
                                            else if(
$gData['premium'] == 3)
                                            {
                                                echo 
'<span style="color:#00FF00";>VIP</span>' 
                                            
}
                                            else if(
$gData['premium'] == 0)
                                            {
                                                echo 
'<span style="color:#FF0000";>NO</span>' 
                                            
?>
                                <hr />
                                Helper: <?php if($gData['helper'] == 1)
                                            {
                                                echo 
'<span style="color:#00FF00";>HELPER</span>' 
                                            
}
                                            else if(
$gData['helper'] == 2)
                                            {
                                                echo 
'<span style="color:#00FF00";>MAPPER</span>' 
                                            
}
                                            else if(
$gData['helper'] == 3)
                                            {
                                                echo 
'<span style="color:#00FF00";>DEVELOPER</span>' 
                                            
}
                                            else if(
$gData['helper'] == 0)
                                            {
                                                echo 
'<span style="color:#FF0000";>NO</span>'
                                            
?>
                                <hr />
                                Admin: <?php if($gData['adminlevel'] == 1)
                                            {
                                                echo 
'<span style="color:#00FF00";>MODERATOR</span>' 
                                            
}
                                            else if(
$gData['adminlevel'] == 2)
                                            {
                                                echo 
'<span style="color:#00FF00";>ADMIN</span>' 
                                            
}
                                            else if(
$gData['adminlevel'] == 3)
                                            {
                                                echo 
'<span style="color:#00FF00";>SENIOR ADMIN</span>' 
                                            
}
                                            else if(
$gData['adminlevel'] == 4)
                                            {
                                                echo 
'<span style="color:#00FF00";>HEAD ADMIN</span>' 
                                            
}
                                            else if(
$gData['adminlevel'] == 5)
                                            {
                                                echo 
'<span style="color:#00FF00";>SERVER OWNER</span>' 
                                            
}
                                            else if(
$gData['adminlevel'] == 0)
                                            {
                                                echo 
'<span style="color:#FF0000";>NO</span>'
                                            
?>
                                <hr />
                                Score: <?php echo number_format($gData['score']); ?>
                                <hr />
                                Cookies: <?php echo number_format($gData['cookies']); ?>
                                <hr />
                                Money: $<?php echo number_format($gData['money']); ?>
                                <hr />
                                Bank Money: $<?php echo number_format($gData['bmoney']); ?>
                                <hr />
                                Total Money: $<?php echo number_format($gData['money'] + $gData['bmoney']); ?>
                                <hr />
                                Group ID: <?php echo number_format($gData['group_id']); ?>
                                <hr />
                                Group Rank: <?php echo number_format($gData['group_rank']); ?>
                                <hr />
                                Member since: <?php echo $gData['reg_time']); ?>
                                <hr />
                                Last login: <?php echo $gData['last_time']); ?>
                                <hr />
                                Kills: <?php echo number_format($gData['kills']); ?>
                                <hr />
                                Deaths: <?php echo number_format($gData['deaths']); ?>
                                <hr />
                                Kill/Death Ratio: <?php echo number_format($gData['kills'] / $gData['kills']); ?>
                                <hr />
                                House ID: <?php echo number_format($gData['house_id']); ?>
                                <hr />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
<?php
include 'includes/footer.php'
?>
Any ideas, my friends? It won't work.
Reply
#2

I can see some mistakes. At <hr /> lines. Other than that idk.. Try checking this site.
https://www.lifewire.com/500-interna...lained-2622938
Reply
#3

Check the error log for the webserver.

Also that's not how you do prepared queries. You're not supposed to do string concatenation. Read up on how that actually works because right now it's still very vulnerable to SQL injection. I also do redirects with a location header (PHP header() function). The W3C discourages using meta refresh for redirects because it messes up browsers' back buttons.
Reply
#4

Quote:
Originally Posted by Vince
Посмотреть сообщение
Check the error log for the webserver.

Also that's not how you do prepared queries. You're not supposed to do string concatenation. Read up on how that actually works because right now it's still very vulnerable to SQL injection. I also do redirects with a location header (PHP header() function). The W3C discourages using meta refresh for redirects because it messes up browsers' back buttons.
I am not that good in PHP ti understand what you are saying, can you just post the fixed code? I would appreciate it.
Reply
#5

The only way you are going to learn is to fix it yourself. Stop being lazy.
Reply
#6

The problem is not in your code,your Web Hosting either does not suport PHP,i've got this problem myself a few weeks ago and I was in need of reinstalling the PHP,or,the PHP version doesn't match and there are old string that you use,or you did not used INDEX.PHP for your first loading page.
You should contact your hosting provider,they can help you with anything about this.
I hope I helped you.
Reply
#7

Quote:
Originally Posted by MrViolence101
Посмотреть сообщение
The only way you are going to learn is to fix it yourself. Stop being lazy.
Some people actually learn from getting help from the internet as well so get off your high horse. There's no 'one way' to learn something.
Reply
#8

Quote:
Originally Posted by BR3TT
Посмотреть сообщение
Some people actually learn from getting help from the internet as well so get off your high horse. There's no 'one way' to learn something.
The difference here is giving the whole fixed code which means he doesn't have to do anything for it to work, and giving the actual help through information and pointers which will mean he has to fix it himself by the knowledge he gains. So I kinda have to agree with MrViolence here.

Vince said you have to check how you make those queries because they're still not completely right. He also said something about the php header function for redirects, you can read up on it here and use that instead of
PHP код:
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=../pages/index.php">'
Information about prepared statements here. Make sure that you check any user input before actually executing the query.

I'll give you a hint, for if you don't know what 'string concatenation' means;
PHP код:
....where reg_id '$charaID'");  //This 
The part where you put that 'charaID' into the prepare function, is not right. You're supposed to put a question mark there and provide that information through 'bind_param'. You can find this info and a good example by folloing the link I provided earlier.
Reply
#9

Quote:
Originally Posted by BR3TT
Посмотреть сообщение
Some people actually learn from getting help from the internet as well so get off your high horse. There's no 'one way' to learn something.
He asked him to fix the code and post the fixed code to this Thread. Can you not read? I said try to fix it yourself, for example googling solutions. Don't blatantly ask for the answer.

So get of your high horse BR3TT.
Reply
#10

Quote:
Originally Posted by MrViolence101
Посмотреть сообщение
He asked him to fix the code and post the fixed code to this Thread. Can you not read? I said try to fix it yourself, for example googling solutions. Don't blatantly ask for the answer.

So get of your high horse BR3TT.
You didn't quote the post of him asking for the fixed code, meaning I took your response as you telling him to go find out himself and to go simply ****** a fix instead of asking for assistance. I agree nobody should be asking for someone to simply fix it, but seeing as you didn't quote that, I thought you were simply telling him that making a thread asking what was wrong wasn't going to help him at all. I apologise for not understanding your reply, I'm used to people quoting to what they're replying to, unless it's the thread itself.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)