shan2batman Posted February 1, 2016 Share Posted February 1, 2016 (edited) hi, guys im trying to debug this issue for 3 days straight and still i have no starting point in the web for this so came here. the problem is everytime when i try to open my home page it displays a 'g' at the top of the document before the header. i dont know where that bug is coming from in my code. the chrome developer tools shows that it loads in the body tag and the page source showed it at the top of the page. Hence double checked the header file where the problem lies but still no solution. please help me out guys. <?php include 'dbconfig.inc.php'; error_reporting(0); $thispage= basename($_SERVER['PHP_SELF']); $thisgroup=""; $aglist=""; $mglist=""; if ($thispage=="group.php") { if (isset($_GET['g'])) { $thisgroup=htmlentities($_GET['g']); $_SESSION['group']=$thisgroup; } } //if (isset($_SESSION['group'])) {} $query="select * from groups"; $stmt11=$conn->prepare($query); $stmt11->execute(); $g_check=$stmt11->rowCount(); $fetch=$stmt11->fetchAll(); if ($g_check>0) { foreach ($fetch as $row) { $aglist.="<span float='right'><td border='solid 2px #'><a href='group.php?g=".$row['name']."'><img src='group/".$row['g_id']."/".$row['logo']."' alt='".$row['name']."' title='".$row['name']."' width='50' height='50'>{$row['name']}</a></td></span>"; } } $sql1="select gm.*, g.* from gmembers as gm left join groups as g on g.creator=gm.mname where gm.mname=:session "; $stmt1=$conn->prepare($sql1); $stmt1->bindValue(":session",$_SESSION['uname']); $stmt1->execute(); //$g_check1=$stmt1->rowCount(); $g_fetch=$stmt1->fetchAll(); $sql="select gm.*,g.* from groups as g left join gmembers as gm on g.name=gm.gname where gm.mname=:session_uname "; $stmt=$conn->prepare($sql); //$stmt->bindValue(":session",$_SESSION['group']); $stmt->bindValue(":session_uname",$_SESSION['uname']); $stmt->execute(); $fetch1=$stmt->fetchAll(); $g_check1=$stmt->rowCount(); if($g_check1>0){ foreach ($fetch1 as $row) { $mglist .="<td border='solid 2px #'><a href='group.php?g=".$row['gname']."&v=".$_SESSION['uname']."'><img src='group/".$row['g_id']."/".$row['logo']."' alt='".$row['gname']."' title='".$row['gname']."' width='50' height='50'>".$row['gname']."</a></td><br><hr>"; } } if(isset($_SESSION['app'])){ $_sql="select count(pm_id) from private_message where (receiver=:sess_uname and has_replies='1' and sread='0') limit 1"; $stmt=$conn->prepare($_sql); $stmt->bindValue(":sess_uname", $_SESSION['uname']); $stmt->execute(); $numrows_n=$stmt->fetch(); if ($numrows_n[0]>0) { $pm_n="<a href='private_message.php?u=".$_SESSION['uname']."'><span style='background: white; height:30px; width:30px;'><img src='img/email153.png' alt='private_message'></span></a>"; } else { $pm_n="<a href='private_message.php?u=".$_SESSION['uname']."'><img src='img/email153.png' alt='private_message_alert'></a>"; } $sql="select count(friend_id) from friends where friend_two=:sess_uname and accepted='0'"; $stmt1=$conn->prepare($sql); $stmt1->bindValue(":sess_uname", $_SESSION['uname']); $stmt1->execute(); $request_count=$stmt1->fetch(); $count_friend=$stmt1->rowCount(); if($request_count[0]>0){ $new_friends="<a href='all_notifications.php'><span style='background: white; height:33px; border-radius:10px; width:30px;'><img src='img/users.png' style='height:25px; width:27px;' alt='new_friends_alert'></span></a>"; }else{ $new_friends="<a href='all_notifications.php'><img src='img/users.png' style='height:25px; width:27px;' alt='new_friends_alert'></a>"; } echo ' <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Protected Area.</title> <link href="http://localhost/project/css/bootstrap.min.css" rel="stylesheet" type="text/css"/> <link href="http://localhost/project/css/custom.css" rel="stylesheet" type="text/css"/> <link href="http://localhost/project/css/jquery.fancybox.css" rel="stylesheet" type="text/css"/> <script src="http://localhost/project/js/jquery-1.11.3.js" type="text/javascript"></script> <script src="http://localhost/project/js/bootstrap.min.js" type="text/javascript"></script> <script src="http://localhost/project/js/custom.js" type="text/javascript"></script> <script src="http://localhost/project/js/respond.js" type="text/javascript"></script> <script src="http://localhost/project/tinymce/js/tinymce/tinymce.min.js" type="text/javascript"></script> <script src="http://localhost/project/js/tinymce.init.js" type="text/javascript"></script> <script src="http://localhost/project/js/jquery.fancybox.js" type="text/javascript"></script> <link type="text/css" rel="stylesheet" href="css/jquery-ui.css"/> <link type="text/css" rel="stylesheet" href="css/jquery-ui.structure.css"/> <link type="text/css" rel="stylesheet" href="css/jquery-ui.theme.css"/> <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js" type="text/javascript"></script> <script src="js/store.min.js" type="text/javascript"></script> <script src="js/jquery-idleTimeout.js" type="text/javascript"></script> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <div class="row"> <header class="header-custom visible-phone visible-tablet visible-desktop"> <div class="head-col-left-custom ">LOGO!</div> <div class="head-col-middle-custom"> <table> <td > <tr class="pull-left"> <input type="text" name="search" class="pull-left input-custom1 search" width="50%" height="30" placeholder="Search by First , Last or username or group name"> </tr> <br> <tr> <div mysearch="mysearch" id="result"> </div> </tr> </td> <td> </td><td class="pull-right"><a href="home.php?u='.$_SESSION["uname"].'">'. $_SESSION["uname"].'</a> | '.$pm_n.' | '.$new_friends.'</td> <td ><div class="dropdown"> <button type="button" class="btn btn-danger dropdown-toggle pull-right" data-toggle="dropdown" aria-expanded="true" >Settings<span class="caret"></span></button> <ul class="dropdown-menu"> <li><a href="http://localhost/project/all_notifications.php" >All Notifications</a></li> <li><a href="http://localhost/project/create_group.php" >Create a group</a></li> <li role="separator"class="divider" ></li> <li><a href="http://localhost/project/options/logout.php" >Logout</a></li> </ul> </div> </td> </table> </div><br> </header> </div> <br> '; } else { error_reporting(0); echo ' <doctype html!> <html> <head> <meta charset="UTF-8"> <title>Activation Area.</title> <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css"/> <link href="css/custom.css" rel="stylesheet" type="text/css"/> <script src="js/jquery-1.11.3.min.js" type="text/javascript"></script> <script src="js/jquery-ui.min.js" type="text/javascript"></script> <script src="js/bootstrap.min.js" type="text/javascript"></script> <script src="js/custom.js" type="text/javascript"></script> <script src="js/respond.js" type="text/javascript"></script> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <div class="row"><header class="header-custom1 visible-phone visible-tablet visible-desktop"> <div class="head-col-left-custom hidden-xs ">LOGO!</div> <div class="head-col-middle-custom1"> <form action="includes/login.inc.php" method="post"> <tr><td>Username: <input type="text" required placeholder="Username" class="input-custom input-group-sm input-sm" name="unamel"> </td></tr> <tr><td>Password:<input class="input-custom input-group-sm input-sm" type="password" name="passl" required placeholder="Password"> <input type="submit" name="submit-login" value="login" class="btn btn-warning btn-danger-custom"> | <a href="forgotpass.php">?Forgot Password</a></p></td></tr> </form> </div> </header> </div> '; } Edited February 1, 2016 by shan2batman Quote Link to comment https://forums.phpfreaks.com/topic/300711-need-help-with-a-strange-behaviour-in-php/ Share on other sites More sharing options...
requinix Posted February 1, 2016 Share Posted February 1, 2016 Forget the developer tools. They show you what the browser interpreted in the HTML. Look at the HTML source of the page to see what PHP actually did. Also, Quote Link to comment https://forums.phpfreaks.com/topic/300711-need-help-with-a-strange-behaviour-in-php/#findComment-1530661 Share on other sites More sharing options...
Solution mac_gyver Posted February 2, 2016 Solution Share Posted February 2, 2016 it's probably something in the 'dbconfig.inc.php' file. Hence double checked the header file where the problem lies or if the posted code is being included/required into another file, it's coming from something in the main file. Quote Link to comment https://forums.phpfreaks.com/topic/300711-need-help-with-a-strange-behaviour-in-php/#findComment-1530662 Share on other sites More sharing options...
shan2batman Posted February 2, 2016 Author Share Posted February 2, 2016 yes mac_gyver i'm including it in home.php and groups.php can it be from them ??? Quote Link to comment https://forums.phpfreaks.com/topic/300711-need-help-with-a-strange-behaviour-in-php/#findComment-1530663 Share on other sites More sharing options...
shan2batman Posted February 2, 2016 Author Share Posted February 2, 2016 (edited) the dbconfig.inc.php seems to be harmless so far??? @requinix here is the page source. Edited February 2, 2016 by shan2batman Quote Link to comment https://forums.phpfreaks.com/topic/300711-need-help-with-a-strange-behaviour-in-php/#findComment-1530664 Share on other sites More sharing options...
requinix Posted February 2, 2016 Share Posted February 2, 2016 Try this: First, get rid of the stupid error_reporting(0);That tells PHP to ignore any possible errors. Then try your script and see anything happens. If not, just before the echo on line 79 add a line header("Content-Type: text/html");Then look for an error message telling you it failed because of output somewhere. Quote Link to comment https://forums.phpfreaks.com/topic/300711-need-help-with-a-strange-behaviour-in-php/#findComment-1530665 Share on other sites More sharing options...
shan2batman Posted February 2, 2016 Author Share Posted February 2, 2016 @requinix sorry bro no luck. it isn't showing any error message. Quote Link to comment https://forums.phpfreaks.com/topic/300711-need-help-with-a-strange-behaviour-in-php/#findComment-1530666 Share on other sites More sharing options...
shan2batman Posted February 2, 2016 Author Share Posted February 2, 2016 @requinix @mac_gyver was right i found the bug in classes file which is required in dbconfig.inc.php, thanks bro Quote Link to comment https://forums.phpfreaks.com/topic/300711-need-help-with-a-strange-behaviour-in-php/#findComment-1530667 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.