beansandsausages Posted July 29, 2007 Share Posted July 29, 2007 Can you please have a look at this.......... if ($_GET['justnews'] == "deletenews"){ mysql_query("DELETE FROM usernews WHERE id = '$id'"); }elseif($justnews == "deleteall"){ mysql_query("DELETE FROM usernews WHERE user = '$info[id]'"); } if (!$_GET[action]) { $resul = mysql_query("SELECT * FROM usernews WHERE user='$info[id]' order by id DESC LIMIT 0,15"); } if (mysql_num_rows($resul)>0) { echo "<b>News:<br></b>"; } while ($news = mysql_fetch_array($resul)){ echo "[<a href=cont.php?justnews=deletenews&id=$news[id]>D</a>] $news[text]<br>"; } if(mysql_num_rows($resul) > 1){ echo "[<a href=cont.php?justnews=deleteall>Clear News</a>]<br>"; } i have glodal functions on but yet the script doesnt delete the post any ideas ..............? Quote Link to comment Share on other sites More sharing options...
trq Posted July 29, 2007 Share Posted July 29, 2007 You have absolutely no error checking in your code. At the very least use... mysql_query($query) or die(mysql_error(); and post the given error. PS: Please enclode your code within [ code ] [ / code ] tags (no spaces) in future. Quote Link to comment Share on other sites More sharing options...
beansandsausages Posted July 29, 2007 Author Share Posted July 29, 2007 sorry didnt realise had to post in in [ code ], i added the mysql_query($query) or die(mysql_error(); and it didnt give any errors Quote Link to comment Share on other sites More sharing options...
trq Posted July 29, 2007 Share Posted July 29, 2007 Where exactly did you add that? And did you add that exactly? Post your current code. Quote Link to comment Share on other sites More sharing options...
beansandsausages Posted July 29, 2007 Author Share Posted July 29, 2007 my code might be a bit pants as i am a n00b at it only been at it past 2 -3 days code is as followed : <?php mysql_connect("localhost", "username", "password") or die(mysql_error()); mysql_select_db("database") or die(mysql_error()); //checks cookies to make sure they are logged in if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { //if the cookie has the wrong password, they are taken to the login page if ($pass != $info['password']) { header("Location: index.php"); } else { $battlesfought = $info[lost] + $info[won] + $info[draw]; if($battlesfought == 0) { $battlesfought += 1; $zero = "yes"; } $percentwon = ($info[won] / $battlesfought) * 100; if($zero == "yes") { $battlesfought -= 1; } $percentwon = sprintf ("%01.2f", $percentwon); $battlesfought1 = $info[lost] + $info[won] + $info[draw]; if($battlesfought1 == 0) { $battlesfought1 += 1; $zero = "yes"; } $percentlost = ($info[lost] / $battlesfought) * 100; if($zero == "yes") { $battlesfought1 -= 1; } $percentlost = sprintf ("%01.2f", $percentlost); $battlesfought2 = $info[lost] + $info[won] + $info[draw]; if($battlesfought2 == 0) { $battlesfought += 1; $zero = "yes"; } $percentdraw = ($info[draw] / $battlesfought) * 100; if($zero == "yes") { $battlesfought2 -= 1; } $percentdraw = sprintf ("%01.2f", $percentdraw); // Hard shit this is like $battlesfought = $info[lost] + $info[won] + $info[draw]; if($battlesfought == 0) { $battlesfought += 1; $zero = "yes"; } $percentwon = ($info[won] / $battlesfought) * 100; if($zero == "yes") { $battlesfought -= 1; } $percentwon = sprintf ("%01.2f", $percentwon); //lost $battlesfought1 = $info[lost] + $info[won] + $info[draw]; if($battlesfought1 == 0) { $battlesfought1 += 1; $zero = "yes"; } $percentlost = ($info[lost] / $battlesfought) * 100; if($zero == "yes") { $battlesfought1 -= 1; } $percentlost = sprintf ("%01.2f", $percentlost); //stalemate $battlesfought2 = $info[lost] + $info[won] + $info[draw]; if($battlesfought2 == 0) { $battlesfought += 1; $zero = "yes"; } $percentdraw = ($info[draw] / $battlesfought) * 100; if($zero == "yes") { $battlesfought2 -= 1; } $percentdraw = sprintf ("%01.2f", $percentdraw); include('top.php'); include('error.php'); echo ' Here at the brother hood, We keep track of every thing you do. '; echo ' <BR> <br> '; // START OF IMAGE SHIT AND PHRASE echo " <img src =\"$info[image]\" alt ='This is curently you game logo'> <br> <a title ='$info[main_phase]' > Phrase One </a> | <a title ='$info[main_sub]'> Phrase Two </a><br>"; $now_then = array("$info[main_phase]","$info[main_sub]",);$hello_mate = $now_then[array_rand($now_then)]; echo " <font size ='5' color =gray><b><u><a title ='Your Current Phrase'> $hello_mate </font></u></b>"; echo "<Br>"; echo " <table align ='left' width =25%> <td> <font size =4><u>Player Stats</u></font> </table> "; if($info[hp] <= 0) { echo " <img src=img\dead.gif alt='Unable to battle, You are Dead' > "; } elseif($info[hp] > 0) { echo " <img src=img\alive.gif alt='Able to battle you have $info[hp]hit points left out of $info[maxhp]'>"; } //WON if($info[won] > 0 || $info[draw] > 0 || $info[draw] > 0) { echo "";} else { } $suckmycock = $info[won] + $info[lost] + $info[draw] ; if ($action == "delete"){$request2 = "DELETE FROM usernews WHERE ID = $id";$result2 = mysql_query($request2,$db);} if ($_GET['justnews'] == "deletenews"){ mysql_query("DELETE FROM usernews WHERE id = '$id'"); }elseif($justnews == "deleteall"){ mysql_query("DELETE FROM usernews WHERE user = '$info[id]'"); } if (!$_GET[action]) { $resul = mysql_query("SELECT * FROM usernews WHERE user='$info[id]' order by id DESC LIMIT 0,15"); } if (mysql_num_rows($resul)>0) { echo "News: "; } while ($news = mysql_fetch_array($resul)){ echo "[<a href=cont.php?justnews=deletenews&id=$news[id]>D[/url]] $news[text] "; } if(mysql_num_rows($resul) > 1){ echo "[<a href=cont.php?justnews=deleteall>Clear News[/url]] "; } include("bottom.php"); }}}?> it all word apart from the if ($_GET['justnews'] == "deletenews"){ mysql_query("DELETE FROM usernews WHERE id = '$id'"); }elseif($justnews == "deleteall"){ mysql_query("DELETE FROM usernews WHERE user = '$info[id]'"); } if (!$_GET[action]) { $resul = mysql_query("SELECT * FROM usernews WHERE user='$info[id]' order by id DESC LIMIT 0,15"); } if (mysql_num_rows($resul)>0) { echo "News: "; } while ($news = mysql_fetch_array($resul)){ echo "[<a href=cont.php?justnews=deletenews&id=$news[id]>D[/url]] $news[text] "; } if(mysql_num_rows($resul) > 1){ echo "[<a href=cont.php?justnews=deleteall>Clear News[/url]] "; } Quote Link to comment Share on other sites More sharing options...
trq Posted July 29, 2007 Share Posted July 29, 2007 Try.... if ($_GET['justnews'] == "deletenews"){ mysql_query("DELETE FROM usernews WHERE id = '$id'") or die(mysql_error()); }elseif($justnews == "deleteall"){ mysql_query("DELETE FROM usernews WHERE user = '$info[id]'") or die(mysql_error()); } Quote Link to comment Share on other sites More sharing options...
beansandsausages Posted July 29, 2007 Author Share Posted July 29, 2007 No still doesnt work. Its not showing any error it just doesnt delete the post. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 29, 2007 Share Posted July 29, 2007 Try: if ($_GET['justnews'] == "deletenews"){ mysql_query("DELETE FROM usernews WHERE id = '".$_GET['id']."'") or die(mysql_error()); }elseif($_GET['justnews']== "deleteall"){ mysql_query("DELETE FROM usernews WHERE user = '$info[id]'") or die(mysql_error()); } Unless you have register_globals turned on, then $justnews and $id are undefined. You need to retreive them from the $_GET array. Quote Link to comment Share on other sites More sharing options...
trq Posted July 29, 2007 Share Posted July 29, 2007 Also place this at the top of your script. <?php error_reporting(E_ALL); ini_set('display_errors','1'); ?> Quote Link to comment Share on other sites More sharing options...
beansandsausages Posted July 29, 2007 Author Share Posted July 29, 2007 i have added error_reporting(E_ALL); ini_set('display_errors','1'); now i have about 100 errors :-\ Quote Link to comment Share on other sites More sharing options...
trq Posted July 29, 2007 Share Posted July 29, 2007 now i have about 100 errors Hence its always best to program with error reporting on. This way you can fix them as they pop up. Now you'll have to fix them to continue. Quote Link to comment Share on other sites More sharing options...
beansandsausages Posted July 29, 2007 Author Share Posted July 29, 2007 what do they mean : Notice: Use of undefined constant lost - assumed 'lost' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 27 Notice: Undefined index: lost in /home/b/l/blades_of_darkness_co_uk/cont.php on line 27 Notice: Use of undefined constant won - assumed 'won' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 27 Notice: Use of undefined constant draw - assumed 'draw' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 27 Notice: Use of undefined constant won - assumed 'won' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 32 Notice: Undefined variable: zero in /home/b/l/blades_of_darkness_co_uk/cont.php on line 33 Notice: Use of undefined constant lost - assumed 'lost' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 36 Notice: Undefined index: lost in /home/b/l/blades_of_darkness_co_uk/cont.php on line 36 Notice: Use of undefined constant won - assumed 'won' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 36 Notice: Use of undefined constant draw - assumed 'draw' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 36 Notice: Use of undefined constant lost - assumed 'lost' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 41 Notice: Undefined index: lost in /home/b/l/blades_of_darkness_co_uk/cont.php on line 41 Notice: Undefined variable: zero in /home/b/l/blades_of_darkness_co_uk/cont.php on line 42 Notice: Use of undefined constant lost - assumed 'lost' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 45 Notice: Undefined index: lost in /home/b/l/blades_of_darkness_co_uk/cont.php on line 45 Notice: Use of undefined constant won - assumed 'won' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 45 Notice: Use of undefined constant draw - assumed 'draw' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 45 Notice: Use of undefined constant draw - assumed 'draw' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 50 Notice: Undefined variable: zero in /home/b/l/blades_of_darkness_co_uk/cont.php on line 51 Notice: Use of undefined constant lost - assumed 'lost' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 56 Notice: Undefined index: lost in /home/b/l/blades_of_darkness_co_uk/cont.php on line 56 Notice: Use of undefined constant won - assumed 'won' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 56 Notice: Use of undefined constant draw - assumed 'draw' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 56 Notice: Use of undefined constant won - assumed 'won' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 61 Notice: Undefined variable: zero in /home/b/l/blades_of_darkness_co_uk/cont.php on line 62 Notice: Use of undefined constant lost - assumed 'lost' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 65 Notice: Undefined index: lost in /home/b/l/blades_of_darkness_co_uk/cont.php on line 65 Notice: Use of undefined constant won - assumed 'won' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 65 Notice: Use of undefined constant draw - assumed 'draw' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 65 Notice: Use of undefined constant lost - assumed 'lost' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 70 Notice: Undefined index: lost in /home/b/l/blades_of_darkness_co_uk/cont.php on line 70 Notice: Undefined variable: zero in /home/b/l/blades_of_darkness_co_uk/cont.php on line 71 Notice: Use of undefined constant lost - assumed 'lost' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 74 Notice: Undefined index: lost in /home/b/l/blades_of_darkness_co_uk/cont.php on line 74 Notice: Use of undefined constant won - assumed 'won' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 74 Notice: Use of undefined constant draw - assumed 'draw' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 74 Notice: Use of undefined constant draw - assumed 'draw' in /home/b/l/blades_of_darkness_co_uk/cont.php on line 79 Notice: Undefined variable: zero in /home/b/l/blades_of_darkness_co_uk/cont.php on line 80 Quote Link to comment Share on other sites More sharing options...
trq Posted July 29, 2007 Share Posted July 29, 2007 Most of these errors are caused by using $arr[key] instead of the proper $array['key']. Quote Link to comment Share on other sites More sharing options...
beansandsausages Posted July 29, 2007 Author Share Posted July 29, 2007 So how would i fix it just add ' ' to the arrays sorry im new to this might just as well give up Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.