Richzilla Posted July 19, 2007 Share Posted July 19, 2007 Over night having changed nothing on my server and my php page I cannot add anything through scripts to my database. The script I was using to great success is below. For absolutely no apparent reason I can no longer update anything to the mySQL databse. Nothing has changed on the working page. I don't even get any error messages, such as cannot connect etc. Is there anything in the setup or admin of mySQL that can be causing this? Essentially, the script below is updating data on the database from a form on the previous page. I'm then echoing out the new result which is correct. However, when going back to the previous page the old data is still there and the database remains unchanged!! What is going wrong??? [code<? $id = $_POST['id']; $event = $_POST['event']; $date = $_POST['date']; $user="xxxx"; $pass="xxxx"; $host = "xxxx"; $dbase="xxxx"; mysql_connect($host,$user,$pass); @mysql_select_db($dbase) or die("Unable to select database"); $query = "UPDATE events SET event='$event' , date='$date' WHERE id='$id'"; $result = mysql_query($query) or die(mysql_error()); $query = "SELECT * FROM events WHERE id='$id'"; $result=mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) { $event = $row['event']; $date = $row['date']; } mysql_close(); ?> <? $page = $_GET['id']; $link = "<a href=http://www.mysite.co.uk/update_event.php?id="; $goback = ">go back</a>"; ?> <br> <table width="900" border="0" align="center"> <tr><td> <span class="trk_list_headers">You have updated the following information on the database : <br /></span>: </td> <table width="900" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td width="30%" align="left"><span class="time_main_text">Event : </span></td> <td width="70%" align="left"><span class="style1"><? echo $event ?></span> <br></td> </tr> <tr> <td width="30%" align="left"><span class="time_main_text">Date : </span></td> <td width="70%" align="left"><span class="style1"><? echo $date ?> </span><br><br /></td> </tr> <tr> </td> <table width="900" align="center"><span class="time_main_text">If this information was incorrect please <? echo "$link$page$goback" ?> and correct the error. </span></td> </table> Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted July 19, 2007 Share Posted July 19, 2007 You might not be getting an error, because you are suppressing it. Change this: @mysql_select_db($dbase) or die("Unable to select database"); To: mysql_select_db($dbase) or die("Unable to select database"); Quote Link to comment Share on other sites More sharing options...
Richzilla Posted July 19, 2007 Author Share Posted July 19, 2007 sorry, yes I've changed that. however, now nothing is gettig echoed in the result, nor is it giving me any errors. anything else you can see? Quote Link to comment Share on other sites More sharing options...
Richzilla Posted July 19, 2007 Author Share Posted July 19, 2007 sorry my bad. i must have somehow cahnged the GET to POST and hence it wasn't pulling in the right ID number. What a plonker!! Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 19, 2007 Share Posted July 19, 2007 good find, just a side not for added speed don't use the generic mysql_fetch_array it creates a indexial array $row[0],$row[1] and a associative key array $row['field1'] $row['field2'] since you are using associative just use mysql_fetch_assoc() it will save you time Quote Link to comment Share on other sites More sharing options...
Barand Posted July 19, 2007 Share Posted July 19, 2007 The "@" was only suppressing the php-generated message. If it failed it should still give the die message 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.