calvinschools Posted May 9, 2011 Author Share Posted May 9, 2011 no database selected Quote Link to comment Share on other sites More sharing options...
calvinschools Posted May 9, 2011 Author Share Posted May 9, 2011 ok the messages are deleting. the header was below everything. completely forgot it has to be above before anything gets sent. but still get a bad photo id. The messages are deleting now though. One more thing and we can put this to rest. Quote Link to comment Share on other sites More sharing options...
fugix Posted May 9, 2011 Share Posted May 9, 2011 when do you get the bad photo id message? show me the script too please Quote Link to comment Share on other sites More sharing options...
calvinschools Posted May 9, 2011 Author Share Posted May 9, 2011 this is the view source. or do you want other code? The bad photo id comes after the comment is deleted. Â <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>What do you know about.......</title> <style type="text/css"> #What { text-align: center; } </style> </head> <body> BAD PHOTO ID<body> <div id="comments"> <form method="POST" action="image_show.php?id="> <label>Name:Â </label><br /><input type="text" name="name" value="" /><br /><br /> <label>Comment:Â </label><br /><textarea name="comment" cols="25" rows="7"></textarea><br /><br /><br /> <input type="submit" name="submit" value="Comment" /><br /> </form></div> <font color="red">Name:</font>Â andrew<br /><br /><font color="red">Comments:</font>Â <br />asshole     <a href="delete.php?id=55">Delete User</a><br /><br /><hr size="5px" width="500px" Â Quote Link to comment Share on other sites More sharing options...
fugix Posted May 9, 2011 Share Posted May 9, 2011 yeah php code too please Quote Link to comment Share on other sites More sharing options...
calvinschools Posted May 9, 2011 Author Share Posted May 9, 2011 here's the image_show.php where the thumbnail is dragged into: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>What do you know about.......</title> <style type="text/css"> #What { text-align: center; } </style> </head> <body> <?php $hostname='g $username='g29'; $password='gw1!'; $dbname='yg $usertable='g mysql_connect('g!') or die(mysql_error()); mysql_select_db("g") or die(mysql_error()); $id = (int)$_GET['id']; if( $id > 0 ) {  $result = mysql_query("SELECT `name`, `photopath`, `state` FROM `photo` WHERE `id` = $id") or die(mysql_error());   $row = mysql_fetch_array( $result );  echo " <img src=\"{$row['photopath']}\" height=\"400px\" width=\"350px\" />". "<br /> ";  echo $row['name']. "\n". "<br/>";  echo $row['state']. "\n"; } else {  echo 'BAD PHOTO ID'; } ?> <?php $hostname='gm'; $username='yg; $password='g; $dbname='g'; $usertable='g $myconn=mysql_connect('your17iue.com', 'yi9', 'Ai!') or die(mysql_error()); mysql_select_db("iu") or die(mysql_error()); $name=$_POST['name']; $comment=$_POST['comment']; $submit=$_POST['submit']; if($submit) {   if($name&&$comment)   {   $query=mysql_query("INSERT INTO comment (id,name,comment) VALUES ('','$name','$comment')");   }   else   {     echo "Please fill out all the fields.";   } } $query_Recordset1 = "SELECT * FROM photo WHERE id=$id"; $Recordset1 = mysql_query($query_Recordset1) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); ?> <body> <div id="comments"> <form method="POST" action="image_show.php?id=<?php echo $row_Recordset1['id'];?>"> <label>Name: </label><br /><input type="text" name="name" value="<?php echo "$name" ?>" /><br /><br /> <label>Comment: </label><br /><textarea name="comment" cols="25" rows="7"></textarea><br /><br /><br /> <input type="submit" name="submit" value="Comment" /><br /> </form></div> <?php $query=mysql_query("SELECT * FROM comment ORDER BY id DESC"); while($rows=mysql_fetch_assoc($query)) {   $id=$rows['id'];   $name=$rows['name'];   $comment=$rows['comment'];   $linkdel="<a href=\"delete.php?id=" . $rows['id'] . "\">Delete User</a>";   echo '<font color="red">Name:</font> ' . $name . '<br />' . '<br />' . '<font color="red">Comments:</font> ' . '<br />' . $comment . ' ' . ' ' .    ' ' . ' ' . $linkdel . '<br />' . '<br />' .   '<hr size="5px" width="500px" color="blue" />' ;  } ?> </body> </html>  and heres the delete.php <?php header("Location: image_show.php?id={$row_Recordset1['id']}"); require('connect.php'); $deleteid=$_GET['id']; mysql_query("DELETE FROM comment WHERE id='$deleteid'") or die(mysql_error()); ?>  i was thinking of putting something like this in delete.php "<img src={$row_Recordset1['photopath']}"; not sure Quote Link to comment Share on other sites More sharing options...
fugix Posted May 9, 2011 Share Posted May 9, 2011 in delete.php...where is your $row_Recordset1['id'] coming from...you must set up your query again before using this for your redirect <?php header("Location: image_show.php?id={$row_Recordset1['id']}"); require('connect.php'); $deleteid=$_GET['id']; mysql_query("DELETE FROM comment WHERE id='$deleteid'") or die(mysql_error()); ?> Quote Link to comment Share on other sites More sharing options...
calvinschools Posted May 9, 2011 Author Share Posted May 9, 2011 from here: Irealized im using to different connect scripts myconn.php and connect.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>The List</title> <style type="text/css"> #a { text-decoration: none; } </style> </head> <body> <div id="header"></div> <?php require_once('myconn.php'); if (!function_exists("GetSQLValueString")) { Â function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { Â Â if (PHP_VERSION < 6) { Â Â Â $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; Â Â } Â Â Â Â $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); Â Â Â Â switch ($theType) { Â Â Â case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; Â Â Â case "long": Â Â Â case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; Â Â Â case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; Â Â Â case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; Â Â Â case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; Â Â } Â Â return $theValue; Â } } $maxRows_Recordset1 = 40; $pageNum_Recordset1 = 0; if (isset($_GET['pageNum_Recordset1'])) { Â $pageNum_Recordset1 = $_GET['pageNum_Recordset1']; } $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1; mysql_select_db($database_myconn, $myconn); //Added ID $query_Recordset1 = "SELECT `id`, `name`, `photopath`, `state` FROM photo ORDER BY `name` ASC"; $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1); $Recordset1 = mysql_query($query_limit_Recordset1, $myconn) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); if (isset($_GET['totalRows_Recordset1'])) { Â $totalRows_Recordset1 = $_GET['totalRows_Recordset1']; } else { Â $all_Recordset1 = mysql_query($query_Recordset1); Â $totalRows_Recordset1 = mysql_num_rows($all_Recordset1); } $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1; ?> <div id="photos"> Â <table border="1" bordercolor="#000000"> Â Â <?php $i=0; Â Â $numperpage=10; ?> Â Â <?php do { ?> Â Â Â <?php if ($i%$numperpage==0) echo "<tr>"; ?> Â Â <td align="center"> Â Â Â Â Â Â <a href="image_show.php?id=<?php echo $row_Recordset1['id'];?>"><img src='<?php echo $row_Recordset1['photopath'] ;?>' height="100" width="100"/></a> Â Â Â <br/> <?php echo $row_Recordset1['name']; ?><br/> <?php echo $row_Recordset1['state']; ?></td> Â Â Â <?php $i++; Â Â Â if ($i%$numperpage==0) echo "</tr>"; ?> Â Â Â <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> Â </table> </div> </body> </html> <?php mysql_free_result($Recordset1); ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
fugix Posted May 9, 2011 Share Posted May 9, 2011 you cant transfer a query from one php page to another like that...write out your query again to get the correct picture id and use that to put in your header dynamic url Quote Link to comment Share on other sites More sharing options...
calvinschools Posted May 9, 2011 Author Share Posted May 9, 2011 now i'm confused. rewrite which query? my head is starting to hurt.Are you saying put another query in delete.php or re-write the main one? Sorry Quote Link to comment Share on other sites More sharing options...
fugix Posted May 9, 2011 Share Posted May 9, 2011 put another one in delete.php, without the query, the call to your row in your db is useless and will return null Quote Link to comment Share on other sites More sharing options...
calvinschools Posted May 9, 2011 Author Share Posted May 9, 2011 im sorry man but I'm just way too confused right now. My brain feels like it gonna ooze out through my ears.  I put this in still bad photo id but I'm pretty sure the query is wrong. I'm not fully grasping this part. Sorry for being a pain. We've been on this for so long  <?php header("Location: image_show.php?id={$row_Recordset1['id']}"); require('connect.php'); mysql_select_db($database_con, $con); $query= mysql_query( "SELECT `id` FROM photo"); $row_id = mysql_fetch_assoc($query); $deleteid=$_GET['id']; mysql_query("DELETE FROM comment WHERE id='$deleteid'") or die(mysql_error()); ?> Quote Link to comment Share on other sites More sharing options...
fugix Posted May 10, 2011 Share Posted May 10, 2011 make it this <?php require('connect.php'); mysql_select_db($database_con, $con); Â $query= mysql_query( "SELECT id FROM photo"); $row_id = mysql_fetch_assoc($query); header("Location: image_show.php?id={$row_id['id']}"); Â $deleteid=$_GET['id']; mysql_query("DELETE FROM comment WHERE id='$deleteid'") or die(mysql_error()); ?> Quote Link to comment Share on other sites More sharing options...
calvinschools Posted May 10, 2011 Author Share Posted May 10, 2011 I think it may be time to stop. Either that or I'm going to smash my computer. BAD PHOTO ID. I have no idea what else to do. First it was the header changed that than it's back to Bad photo id. Quote Link to comment Share on other sites More sharing options...
fugix Posted May 10, 2011 Share Posted May 10, 2011 I think it may be time to stop. Either that or I'm going to smash my computer. BAD PHOTO ID. I have no idea what else to do. First it was the header changed that than it's back to Bad photo id. Â yeah im getting rather frustrated myself...but i will leave you with this....the way that you got the photo id's for the photos so when you click on a photo it shows correctly, you want to use that exact same method on everything that will be either redirecting to that page, or submitting to that page, so that you do not lose your $_GET['photoid']; since you have a dynamic url in (image_show?id=), it is crucial that you maintain the correct id on the end of the url, so that you do not lose the ability to get that id via $_GET['photoid'], that is whats hapening here. when you redirect to the image_show page again after deleting your comment, you are losing that id...i would actually advise that you write your "delete comment" code on your image_show.php page. That way there is no need to redirect and you wont lose your photoid Quote Link to comment Share on other sites More sharing options...
calvinschools Posted May 10, 2011 Author Share Posted May 10, 2011 thats a good idea. Im going to try that. Again thanks so much for all the help. You have no idea how much i appreciate it. If anything else and hopefully there wont be, I'll save it for tomorrow. I think I need to take a break than look at everything again because its all become one big mess of code to me. I'll talk to you later. Thanks Quote Link to comment Share on other sites More sharing options...
fugix Posted May 10, 2011 Share Posted May 10, 2011 thats a good idea. Im going to try that. Again thanks so much for all the help. You have no idea how much i appreciate it. If anything else and hopefully there wont be, I'll save it for tomorrow. I think I need to take a break than look at everything again because its all become one big mess of code to me. I'll talk to you later. Thanks good idea..sometimes its good to step away and come back later..if you ever need help with anything else il be here.. 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.