PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 19th, 2012, 06:51 AM
helenp helenp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383 helenp Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 6 Days 8 h 41 m 34 sec
Reputation Power: 0
Several inserts and delets, always one failing

Hi,
I have this script to save old properties in another table then I delete from other tables, the strange is, there is always one that fails, before one of the deletes failed, I changed the way of the delete and then the last insert failed. I just dont get it.

This is what I have at this moment and the insert that does not work is the last one, being the column and tablename correct:

Code:
  mysql_query($query);
$query = "INSERT INTO buscador_old SELECT * FROM buscador WHERE `id_propiedad` = '$id_propiedad'";

  mysql_query($query);
$query = "INSERT INTO availability_old (id_propiedad, tipo, zona, duermen, link_ingles, link_esp, link_sve, conditions, condiciones, villkor)
 SELECT id_propiedad, tipo, zona, duermen, link_ingles, link_esp, link_sve, conditions, 
 condiciones, villkor  FROM casa WHERE `id_propiedad` = '$id_propiedad'";
 
   mysql_query($query);
$query = "INSERT INTO Casas_alquilar_old SELECT * FROM Casas_alquilar WHERE `nombre` = '$id_propiedad'";

  mysql_query($query); 
   $query = "INSERT INTO casa_old (id_propiedad)" .
"VALUES ('$id_propiedad')";

$sql = mysql_query ("DELETE FROM `casa` WHERE `id_propiedad` = '$id_propiedad'");
 
$sql = mysql_query ("DELETE FROM `buscador` WHERE `id_propiedad` = '$id_propiedad'");

$sql = mysql_query("DELETE FROM `Casas_alquilar` WHERE `nombre` = '$id_propiedad'");


Any help please, as if I do changes so the failing works, then another one fails....

Reply With Quote
  #2  
Old November 19th, 2012, 09:16 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 26,371 r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 6 h 29 m 14 sec
Reputation Power: 4140
i'm sorry, i have never seen the error message "does not work" before

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book

Reply With Quote
  #3  
Old November 19th, 2012, 10:17 AM
cafelatte cafelatte is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Mar 2008
Posts: 1,923 cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 5 Days 16 h 21 m 8 sec
Reputation Power: 377
>i'm sorry, i have never seen the error message "does not work" before

That's weird, because that error message shows up in this very forum alarmingly often!

;-)

Reply With Quote
  #4  
Old November 19th, 2012, 10:40 AM
helenp helenp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383 helenp Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 6 Days 8 h 41 m 34 sec
Reputation Power: 0
Thanks
The thing is I have not done in phpmysql as the inserts and deletes works perfectly separately, but as I said when doing them all together there is always one that is not inserted or deleted, if I change the php to make the failing one to work then another one does not work anymore, I need to do the inserts and deletes all at the same time so must be done with php, if I do them one by one I dont have any problem at all. Therefore I dont get it.

The problem is not doing them separately, its when done all together. Dont know how to do all at the same time to test in phpmyadmin.

Reply With Quote
  #5  
Old November 19th, 2012, 11:21 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 26,371 r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 6 h 29 m 14 sec
Reputation Power: 4140
contrary to popular belief, phpmyadmin does not run multiple sql statements

it runs them one at a time, just like you have to do, except it does them one after the other so that it only looks like it's doing multiple statements

and you still did not explain what "does not work" means


Reply With Quote
  #6  
Old November 19th, 2012, 11:27 AM
helenp helenp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383 helenp Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 6 Days 8 h 41 m 34 sec
Reputation Power: 0
Quote:
Originally Posted by r937
contrary to popular belief, phpmyadmin does not run multiple sql statements

it runs them one at a time, just like you have to do, except it does them one after the other so that it only looks like it's doing multiple statements

and you still did not explain what "does not work" means



Does not work, means, it does not do what it´s supposed to do, ie insert or update, I done changes many time in this code, and I always ends up with one not working, inserting or deleting depending, the way the statements are done above it´s the last insert that does not work, the one before the 3 deletes.
Thanks
So I suppose the problem is in the php handling the sql.

Reply With Quote
  #7  
Old November 19th, 2012, 11:34 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 26,371 r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 6 h 29 m 14 sec
Reputation Power: 4140
okay, i'm gonna move this thread to the php forum, as php seems to be where you are having the problem

Reply With Quote
  #8  
Old November 19th, 2012, 11:44 AM
helenp helenp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383 helenp Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 6 Days 8 h 41 m 34 sec
Reputation Power: 0
Quote:
Originally Posted by r937
okay, i'm gonna move this thread to the php forum, as php seems to be where you are having the problem

Thanks did not thought about that.

Reply With Quote
  #9  
Old November 19th, 2012, 01:18 PM
jpmul jpmul is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2012
Posts: 27 jpmul User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 38 m 44 sec
Reputation Power: 0
This should work

PHP Code:
 $query "INSERT INTO buscador_old SELECT * FROM buscador WHERE `id_propiedad` = '$id_propiedad'";
mysql_query($query);

$query "INSERT INTO availability_old (id_propiedad, tipo, zona, duermen, link_ingles, link_esp, link_sve, conditions, condiciones, villkor)
 SELECT id_propiedad, tipo, zona, duermen, link_ingles, link_esp, link_sve, conditions, 
 condiciones, villkor  FROM casa WHERE `id_propiedad` = '
$id_propiedad'";
mysql_query($query);

$query "INSERT INTO Casas_alquilar_old SELECT * FROM Casas_alquilar WHERE `nombre` = '$id_propiedad'";
mysql_query($query); 

$query "INSERT INTO casa_old (id_propiedad)" .
"VALUES ('$id_propiedad')";
mysql_query($query); 


$sql "DELETE FROM `casa` WHERE `id_propiedad` = '$id_propiedad'";
mysql_query($sql);


$sql "DELETE FROM `buscador` WHERE `id_propiedad` = '$id_propiedad'";
mysql_query($sql);


$sql mysql_query("DELETE FROM `Casas_alquilar` WHERE `nombre` = '$id_propiedad'";
mysql_query($sql); 

Reply With Quote
  #10  
Old November 19th, 2012, 02:43 PM
helenp helenp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383 helenp Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 6 Days 8 h 41 m 34 sec
Reputation Power: 0
Quote:
Originally Posted by jpmul
This should work

PHP Code:
 $query "INSERT INTO buscador_old SELECT * FROM buscador WHERE `id_propiedad` = '$id_propiedad'";
mysql_query($query);

$query "INSERT INTO availability_old (id_propiedad, tipo, zona, duermen, link_ingles, link_esp, link_sve, conditions, condiciones, villkor)
 SELECT id_propiedad, tipo, zona, duermen, link_ingles, link_esp, link_sve, conditions, 
 condiciones, villkor  FROM casa WHERE `id_propiedad` = '
$id_propiedad'";
mysql_query($query);

$query "INSERT INTO Casas_alquilar_old SELECT * FROM Casas_alquilar WHERE `nombre` = '$id_propiedad'";
mysql_query($query); 

$query "INSERT INTO casa_old (id_propiedad)" .
"VALUES ('$id_propiedad')";
mysql_query($query); 


$sql "DELETE FROM `casa` WHERE `id_propiedad` = '$id_propiedad'";
mysql_query($sql);


$sql "DELETE FROM `buscador` WHERE `id_propiedad` = '$id_propiedad'";
mysql_query($sql);


$sql mysql_query("DELETE FROM `Casas_alquilar` WHERE `nombre` = '$id_propiedad'";
mysql_query($sql); 


Puf, that worked, thousands of thanks, had many irritations with that script.

Reply With Quote
  #11  
Old November 19th, 2012, 02:54 PM
ptr2void ptr2void is offline
I haz teh codez!
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Dec 2003
Posts: 2,476 ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 5 h 48 m 16 sec
Reputation Power: 2194
Uh, you might want to look into transactions.
__________________
I ♥ ManiacDan & requinix

This is a sig, and not necessarily a comment on the OP:
Please don't be a help vampire!

Reply With Quote
  #12  
Old November 19th, 2012, 03:29 PM
helenp helenp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383 helenp Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 6 Days 8 h 41 m 34 sec
Reputation Power: 0
Quote:
Originally Posted by ptr2void
Uh, you might want to look into transactions.

Yes, maybe, but that script is rarely used and only by me, but its good to know about it, thanks

Reply With Quote
  #13  
Old November 19th, 2012, 04:12 PM
jpmul jpmul is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2012
Posts: 27 jpmul User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 38 m 44 sec
Reputation Power: 0
glad i could help

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Several inserts and delets, always one failing

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap