dolcezza Posted November 24, 2007 Share Posted November 24, 2007 Can anyone please help me figure out why this isn't working? I am new at this and having alot of trouble. I get a blank page, not even an error. $id = $_GET[id]; $query = "DELETE FROM contacts WHERE id='$id'"; $result = mysql_query($query) or die ("Error in query: $query.".mysql_error()); I'm getting the id from <a href='delete.php?id=<?=$id;?>'>delete</a> Thanks! Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 24, 2007 Share Posted November 24, 2007 is this your full code does the record get deleted from the db ? more information is required Quote Link to comment Share on other sites More sharing options...
dolcezza Posted November 24, 2007 Author Share Posted November 24, 2007 the record isn't getting deleted from database. full code on that page: <?php include_once("connect.php") $id = $_GET[id]; $query = "DELETE FROM contacts WHERE id='$id'"; $result = mysql_query($query) or die ("Error in query: $query.".mysql_error()); full code from page where id is coming from: <?php include_once("connect.php"); $id=$_GET['id']; $query="SELECT * FROM contacts ORDER BY last ASC"; $result=mysql_query($query); // count how many rows are in the table $num=mysql_num_rows($result); mysql_close(); ?> <table border="0" cellspacing="2" cellpadding="2"> <tr> <th>Name</th> <th>Venue></th> <th>Phone</th> <th>Mobile</th> <th>Fax</th> <th>E-mail</th> <th>Website</th> <th>Address></th> <th>City</th> <th>State</th> <th>Zip</th> <th>Notes</th> </tr> <?php //loop if ($num==0) {echo"The database contains no records";} else { $i=0; while($i<$num){ $id=mysql_result($result,$i,"id"); $first=mysql_result($result,$i,"first"); $last=mysql_result($result,$i,"last"); $venue=mysql_result($result,$i,"venue"); $phone=mysql_result($result,$i,"phone"); $mobile=mysql_result($result,$i,"mobile"); $fax=mysql_result($result,$i,"fax"); $email=mysql_result($result,$i,"email"); $website=mysql_result($result,$i,"website"); $address=mysql_result($result,$i,"address"); $city=mysql_result($result,$i,"city"); $state=mysql_result($result,$i,"state"); $zip=mysql_result($result,$i,"zip"); $notes=mysql_result($result,$i,"notes"); ?> <tr> <td><? echo $last.", ".$first; ?></td> <td><? echo $venue; ?></td> <td><? echo $phone; ?></td> <td><? echo $mobile; ?></td> <td><? echo $fax; ?></td> <td><a href="mailto:<? echo $email; ?>">E-mail</a></td> <td><? echo $website; ?></td> <td><? echo $address; ?></td> <td><? echo $city; ?></td> <td><? echo $state; ?></td> <td><? echo $zip; ?></td> <td><? echo $notes; ?></td> <td><a href='delete.php?id=<?=$id;?>'>delete</a></td> </tr> <? $i++; } } echo "</table>"; ?> Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 24, 2007 Share Posted November 24, 2007 try this <?php include_once("connect.php") $id = $_GET[id]; $query = "DELETE FROM contacts WHERE id='$id'"; if (mysql_query($query)) { echo "Record deleted sucessfully"; } else { echo "There was an error in deletion : ".mysql_error(); } Quote Link to comment Share on other sites More sharing options...
dolcezza Posted November 24, 2007 Author Share Posted November 24, 2007 still just a blank page and not deleting Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 24, 2007 Share Posted November 24, 2007 actually the code for that page should be, forgot to put the closing php tag <?php include_once("connect.php") $id = $_GET[id]; $query = "DELETE FROM contacts WHERE id='$id'"; if (mysql_query($query)) { echo "Record deleted sucessfully"; } else { echo "There was an error in deletion : ".mysql_error(); } ?> Quote Link to comment Share on other sites More sharing options...
dolcezza Posted November 24, 2007 Author Share Posted November 24, 2007 still not working. Same blank page. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 24, 2007 Share Posted November 24, 2007 Blank pages are usually caused by fatal parse or runtime errors. In this case the include_once() statement is missing the semi-colon ; at the end of the statement. When learning, developing code, or debugging code, always check your web server log for errors and/or turn on full php error reporting in php.ini or .htaccess (fatal parse errors won't be output to the browser if you attempt to turn on error reporting in your script.) Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 24, 2007 Share Posted November 24, 2007 I totally overlooked that while giving a solution , that would be the error Quote Link to comment Share on other sites More sharing options...
dolcezza Posted November 24, 2007 Author Share Posted November 24, 2007 Thank you so much, it works now. The server will not allow me to turn on error reporting. I'm going to have to setup a testing server eventually I guess. Oh, and I should probably read over when others give me a solution, I was just so anxious to make it work! Thanks to both of you. Now lets see if I can figure out my next issue myself :-\ 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.