Page 1 of 1

Code Stopped Working, I made no changes at all.

Posted: Sat Jun 03, 2006 11:18 am
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

Posted: Sat Jun 03, 2006 11:22 am
by nickman013
I found out what was wrong with it. Thanks anyway.

Posted: Sat Jun 03, 2006 11:34 am
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?

Posted: Sat Jun 03, 2006 11:47 am
by nickman013
I didnt select anything to be outputted from the database.

Posted: Sat Jun 03, 2006 1:35 pm
by Chris Corbyn
MrPotatoes wrote:what was the error?
My guess: Register Globals was off on the server he/she tried it on ;)