Code Stopped Working, I made no changes at all.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Code Stopped Working, I made no changes at all.

Post by nickman013 »

Hello,

I have a code that posts information to a page from a database. It worked perfect, I havnt edited the code in a while, and now all of a sudden I am getting an error.

The code is

Code: Select all

<?
$page = "muot report.";
$ip = @$REMOTE_ADDR; 
include("/home/muot/public_html/site/includes/top.php");
?>
<!--START CONTENT-->
<div id=report_contents>
Click <a href=/site/muotReport/submitMuot.php>here</a> to submit a MUOT. <br>
Click <a href=/site/muotReport/previousMuots.php>here</a> to see previous muots.
</div><br><BR>
<div id=m_contents>
<center>
<?
error_reporting('e_all');
$username2= "muot_report";  
$password2= "password";  
$database2= "muot_report";  
$connection2 = mysql_connect('localhost',$username2,$password2);  
mysql_select_db($database2); 
$sql2 = "SELECT * FROM `report` WHERE Live = 1";
$result = mysql_query($sql2) or die(mysql_error());
$row = mysql_fetch_assoc($result); 
echo $row['Code'];
?><br><br>
<form action=/site/muotReport/addComment.php method=post>
<center><font color=red size=1><b>Your IP will be recorded, submitting a mean comment, will result in a ban from this website.</font></b></center><br>
<table border=1 width=500>
	<tr>
		<td>
			Your Name:
		</td>
		<td><input type=text size=23 name=yourname></td>
	</tr>
	<tr>
		<td>Your Comment:</td>
		<td><textarea rows=10 name=comments></textarea></td>
	</tr>
<tr><td colspan=2 align=center><input type=hidden name=who value="<? echo $row['Number']; ?>">	<input type=submit></td></tr><input type=hidden name=ip value=<? echo $ip; ?>>
</table>
</form>
<table border=0 width=500><tr><td><b>NAME</b></td><td><b>COMMENT</b></td></tr>
<?
$sql4 = "SELECT * FROM `comments` WHERE who =" . $row['Number'] . " ORDER BY `id` DESC"; 
$result4 = mysql_query($sql4) or die(mysql_error()); 
while($row4 = mysql_fetch_array($result4)) { 
echo "<tr>"; 
echo "<td align=left width=100 valign=top>".$row4['name']."</td>"; 
echo "<td align=left width=400>".$row4['comment']."</td>";
echo "</tr>";
echo "<tr>"; 
echo "<td>";
echo " ";
echo "</td>";
echo "</tr>";
} mysql_close($connection2); 
?>
</table>
</center>
<!--END CONTENT-->
<?
echo $_SESSION['screenname'];
include("/home/muot/public_html/site/includes/bottom.php");
?>
The error I get is
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY `id` DESC' at line 1
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

I found out what was wrong with it. Thanks anyway.
User avatar
MrPotatoes
Forum Regular
Posts: 617
Joined: Wed May 24, 2006 6:42 am

Post by MrPotatoes »

browsers that cache a page make it so that your code works as it did before you refresh. IE doesn't so it's good for testing and debugging.

what was the error?
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

I didnt select anything to be outputted from the database.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

MrPotatoes wrote:what was the error?
My guess: Register Globals was off on the server he/she tried it on ;)
Post Reply