Emergency - All records replaced
Moderator: General Moderators
Emergency - All records replaced
Has anyone experienced this problem,
This morning I entered the edit form of my system and edited a person record when I pressed the save button it automatically replaced all 1000 records with the edited record I had just changed. This code has worked fine for 2 years how could this suddently happen??
Any IDEAS???
This morning I entered the edit form of my system and edited a person record when I pressed the save button it automatically replaced all 1000 records with the edited record I had just changed. This code has worked fine for 2 years how could this suddently happen??
Any IDEAS???
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: EMERGENCY - ALL RECORDS REPLACED
Your WHERE clause probably has a bug in it. Hopefully you have a backup to restore from?mohson wrote:Has anyone experienced this problem,
This morning I entered the edit form of my system and edited a person record when I pressed the save button it automatically replaced all 1000 records with the edited record I had just changed. This code has worked fine for 2 years how could this suddently happen??
Any IDEAS???
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Becuase the integrity of your data has been ok for 2 years and something's now not right? Databases can seem to be working fine and dandy until you lose a bit of data integrity and then everything can go pear shaped.mohson wrote:yeh I do have a back up. but why would my where clause suddenly have a bug when its been fine for 2 years?
Please stop bumping your thread...
...i know your issue is urgent, but people will reply if they have an answer![url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:4. All users of any level are restricted to bumping (as defined here) any given thread within twenty-four (24) hours of its last post. Non-trivial posts are not considered bumping. A bump post found in violation will be deleted, and you may or may not recieve a warning. Persons bumping excessively be considered as spammers and dealt with accordingly.
Apologies for that guys, I was just panicking. Again I apologise for doing this and understand completely the logic behind it.
Ok one thing I dont understand is that this code has never changed, I also use this code for all my other edit functions and they are currently functioning correctly why is this the case?
Heres my code
And then you have all the form informationetc etc etc
and then you have the where clause
Ok one thing I dont understand is that this code has never changed, I also use this code for all my other edit functions and they are currently functioning correctly why is this the case?
Heres my code
Code: Select all
* Connecting, selecting database */
$link = mysql_connect("vxxxx", "xxx", "xxxx")
or die("Could not connect : " . mysql_error());
echo "";
mysql_select_db("contact_management_system") or die("Could not select database");
if(isset($_GET['person_id'])){
$person_id=$_GET['person_id'];
}
if ($_POST['Submit'] == 'Save'){
foreach ($_POST as $formName => $phpName){
$$formName = $phpName;
}
$sql ="UPDATE people SET "
. " salutation='" .$salutation."',"
. " firstname='" .$firstname ."',"
. " surname='" .$surname."',"
. " organisation='" .$organisation ."',"
. " role='" .$role."',"
. " address1='" . $address1."',"
. " address2='" .$address2."',"
. " city='" .$city."',"
. " telephone='" .$telephone."',"
. " mobile='" . $mobile ."',"
. " fax='" .$fax."',"
. " dateoflastcontact='" .$dateoflastcontact."',"
. " datecontactagain='" .$datecontactagain."',"
. " notes='" .$notes."',"
. " email='" .$email."',"
. " org_id='" . $org_id ."'";and then you have the where clause
Code: Select all
$sql = "SELECT * FROM people WHERE person_id='" . $person_id . "'";
//echo "<br><div align=center>" . $sql . "<br>";
echo "<br><div align=center><br>";
$memb = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($memb);What is after
Is that the last line of $sql in your first post? That never would have worked, and would have always updated all the records. Is this the first time you have updated a record?
Code: Select all
. " org_id='" . $org_id ."'";Thanks astions Ive now corrected this but im now getting this error message
could not insertYou have an error in your SQL syntax near 'WHERE person_id='3'' at line 1
heres the code
Any Ideas?
could not insertYou have an error in your SQL syntax near 'WHERE person_id='3'' at line 1
heres the code
Code: Select all
$sql ="UPDATE people SET "
. " salutation='" .$salutation."',"
. " firstname='" .$firstname ."',"
. " surname='" .$surname."',"
. " organisation='" .$organisation ."',"
. " role='" .$role."',"
. " address1='" . $address1."',"
. " address2='" .$address2."',"
. " city='" .$city."',"
. " telephone='" .$telephone."',"
. " mobile='" . $mobile ."',"
. " fax='" .$fax."',"
. " dateoflastcontact='" .$dateoflastcontact."',"
. " datecontactagain='" .$datecontactagain."',"
. " notes='" .$notes."',"
. " email='" .$email."',"
. " WHERE person_id='" . $person_id."'";