Jump to content

[SOLVED] basic php help


SN1P3R_85

Recommended Posts

On one of my pages, none of the css is displayed, and neither is a certain table. If i take the html and put it in a file, it works fine, but in combination with the php, it doesn't work. Here is the code for the table, can you guys see anything wrong with it?:

 

echo '<table class="forum_menu" border="1" width="10%">';

while ($row = mysql_fetch_assoc($sql_query))

{

echo '<tr style="height:20px"><td class="forum" width="50%"><a href="/forum/forum_display.php?id=' . $row['Thread_id'] . '>' .

$row['Thread_name'] . '</td></tr>';

}

echo "</table>";

Link to comment
https://forums.phpfreaks.com/topic/124142-solved-basic-php-help/
Share on other sites

there are no syntax errors...

try looking in the source code to see if something does not look right or if the code is completely absent. Try adding the line error_reporting(E_ALL) to the top of the page if no errors are currently being displayed. Post your script here and we can try to help.

I added that line. all i got is this: Notice: Undefined index: User_level in /homepages/12/d222097102/htdocs/user.inc on line 11. This is a different script, and that undefined index is because of whitespace i think. Anyways, it shouldn't have anything to do with the forum_menu.php file.

<?php

error_reporting(E_ALL);

include('../user.inc');

include('../SQL_PASS.inc');

 

if(!$user)

{

header('Location:http://www.caidenhome.com/access_denied.php');

}

 

if(!$con)

{

die('could not connect: ' . mysql_error());

}

 

if(!$db_select)

{

die('could not select database: ' . mysql_error());

}

 

$sql_fetch = "SELECT * FROM `threads`";

$sql_query = mysql_query($sql_fetch);

 

if(!$sql_fetch)

{

die('could not run query: ' . mysql_error());

}

 

if (mysql_num_rows($sql_query)==0)

{

echo "<p>there are no threads at the moment</p>";

}

else

{

echo '<table class="forum_menu" border="1" width="10%">';

while ($row = mysql_fetch_assoc($sql_query))

{

echo '<tr style="height:20px"><td class="forum" width="50%"><a href="/forum/forum_display.php?id=' . $row['Thread_id'] . '>' . $row['Thread_name'] . '</td></tr>';

}

echo "</table>";

}

 

?>

 

<html>

 

<head>

<title>forum_menu</title>

<link rel="stylesheet" type="text/css" href="/css/standard.css" />

</head>

 

<body>

 

<table class="lnk_bar" border="1" width="100%">

<tr>

<td width="20%"><b><a href="/index.php">home</a></b></td>

<td width="20%"><b><a href="/calc.php">calculator</a></b></td>

<td width="20%"><b><a href="/cobolt.mp3">song</a></b></td>

<td width="20%"><b><a href="/forums/forum_menu.php">forum</a></b></td>

<td width="20%"><b><a href="/register.php">register</a></b></td>

</tr>

</table>

 

<a class="thread_create" href="/forum/create_thread.php">start thread</a>

 

</body>

</html>

change the line

 

if(!$sql_fetch)

to

if(!$sql_query)

 

and see if that displays the "could not run query...." error.

 

edit: also, the error you're getting is because you're using an array index that doesn't exist... such as $array['User_level']; where "User_level" is not an existing key.

im pretty sure the part thats messing it up is this, because when i comment it out, the page displays fine.

 

 

echo '<table class="forum_menu" border="1" width="10%">';

 

while ($row = mysql_fetch_assoc($sql_query))

{

echo '<tr style="height:20px"><td class="forum" width="50%"><a href="/forum/forum_display.php?id=' . $row['Thread_id'] . '>' . $row['Thread_name'] . '</td></tr>';

}

echo "</table>";

now I see it

 

echo '<table class="forum_menu" border="1" width="10%">';

while ($row = mysql_fetch_assoc($sql_query))
{
echo '<tr style="height:20px"><td class="forum" width="50%"><a href="/forum/forum_display.php?id=' . $row['Thread_id'] . '">' . $row['Thread_name'] . '</a></td></tr>';
}
echo "</table>";

 

is what you should change it to... look for the quote and < /a> I added at the end of the <a> tag.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.