PHP not working

I have this code and when applied to my page it makes that page go blank. when i remove this code from the page the page goes back to normal. I cant figure out whats wrong with it.

[php]<?php
$thisPage = basename($_SERVER[‘PHP_SELF’]);
$thisGroup = “”;
$agList = “”;
$mgList = “”;
$_SESSION[‘group’] = “notSet”;
if ($thisPage == “group.php”){
if(isset($GET[“g”])){
$thisGroup = preg_replace(’#[^a-z0-9
]#i’, ‘’, $_GET[‘g’]);
$_SESSION[‘group’] = $thisGroup;
}
}
if (isset($_SESSION[‘username’])) {
// All groups list
$query = mysqli_query($db_connect, “SELECT name,logo FROM groups”);
$g_check = mysqli_num_rows($query) or die (mysqli_error($db_connect));
if ($g_check > 0){
while ($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) {
$agList .= ‘<a href="group.php?g=’.$row[“name”].’"><img src=“groups/’.$row[“name”].’/’.$row[“logo”].’” alt="’.$row[“name”].’" title="’.$row[“name”].’" width=“50” height=“50” border=“0” />’;
}
}
// My groups list
$sql = “SELECT gm.gname, gp.logo
FROM gmembers AS gm
LEFT JOIN groups AS gp ON gp.name = gm.gname
WHERE gm.mname = ‘$log_username’”;
$query = mysqli_query($db_connect, $sql);
$g_check = mysqli_num_rows($query);
if ($g_check > 0){
while ($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) {
$mgList .= ‘'.$row['gname'].'’;
}
}
}
?>[/php]

Post the ENTIRE page.

This is an include page to other pages. When i include this it blanks out the site.

Turn error reporting on.

What he said…

Also, you need to fix your quotes in two of your lines.

This line:

$agList .= ''.$row[';
is one of them....

You have double-quotes used inside of double-quotes. That will not work. Change all of your $row[] to use
the base that you selected which is single-quotes. And, it should fix you up. You must think of quotes very
carefully when you nest them. If you nest a double-quote inside of a single-quote as you did with the start
of the HREF, and then end the single quote, the next quote used should be another single quote. And, so,
otherwise, your quotes will not be ordered as they should be and will end up with an mess when it is then
displayed on the screen.

So, try changing all of the $row[] parts of your line to use single-quotes to match how you started your
string out with. I think that is the issue…

[php]$agList .= ‘<a href="group.php?g=’.$row[“name”].’"><img src=“groups/’.$row[“name”].’/’.$row[“logo”].’” alt="’.$row[“name”].’" title="’.$row[“name”].’" width=“50” height=“50” border=“0” />’;[/php]

I see nothing wrong with that line of code? The OP doesn’t have double quotes inside double quotes for there is a single quote before the double quotes and after the double quotes in $row[“name”] separated properly with a period. (Now that’s a tongue twister ;D)

Interestingly, it works in two of my editor’s, but, not in one of them. Seems there is an odd thing going
on with the one I used… Sorry everyone… LOL ME-BAD! And sorry to make it a tongue twister! :wink:

So, Camirandra, did you VIEW-SOURCE of your output to see what point the code is dying at?
If you right-click on the viewed page and VIEW-SOURCE, you might see some hints to where the error is.

Also, as Astonecipher mentioned turn on error reporting. Add these to the beginning of the page:
[php]
ini_set(‘display_errors’,1);
error_reporting(E_ALL);
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service