View Full Version : PHP / MySQL

02-18-2008, 08:23 PM
Hey Guys!

I cannot get my code to work, I don't get any errors! I'm sure its some really simple but I just can't spot it!

$user = $_SESSION['MM_Username'];

if(isset($_GET['del'])) {
$del_id = $_GET['del'];
mysql_query("UPDATE favs SET user = '' WHERE id = '$del_id' AND user = '$user'") or die('<div class="passbad">Sorry there was an error!</div>');
echo '<div class="addfav">The selected favorite was successfully deleted! <a href="favs.php">Close</a>!</div><br />';

$result = mysql_query("SELECT * FROM favs WHERE user = '$user' ORDER BY title ASC") or die('<div class="passbad">Sorry there was an error!</div>');
echo '<div class="bb">';
while($row = mysql_fetch_array($result)) {
echo '<div class="itemcontianer" style="border-left: #333333 1px solid; border-right: #333333 1px solid;">
<table cellpadding="0" cellspacing="0" width="780">
<div class="itemtitle"0>
<a href="'.$row['url'].'">'.$row['title'].'</a>

<div class="itemdescription">
<td align="right" valign="middle">
<div align="right">
<a href="favs.php?del='.$row['id'].'" return false;" class="menulink"><img src="images/del.gif" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;</div></td></tr></table></div>';
echo '</div>';


~ Christian

Andrew Johnson
02-18-2008, 10:06 PM
Well I don't see a SESSION_START() but you are using session variables...

02-18-2008, 10:22 PM
I cannot get my code to work, I don't get any errors!

Doctor, doctor. I'm sick, please fix me!


Doctor, my leg stopped moving. Please make it move again.

02-19-2008, 02:51 AM
aedrin is trying to be funny, but what I think he is trying to say, is that even without errors, you can still tell us what it is supposed to do, and what it is/isn't doing instead.

Errors may be turned off, but the things I see are these:
(As mentioned,) You are using SESSION variables without starting the session.
You are not verifing that your query worked before you try to use it. Try this:

while($result && mysql_num_rows($result)>=1 && $row = mysql_fetch_array($result))

02-19-2008, 03:22 PM
aedrin is trying to be funny

While I was trying to insert some humor, I was hoping the-dream would figure out what I was saying by himself. He's been around for quite a while, but still makes the same mistakes as newcomers make (untested queries...).