ukscotth Posted July 16, 2009 Share Posted July 16, 2009 Hi, Whenever I run this script my server freaks out and I end up having to reboot it. Any ideas why ? there are 19000 pictures but ive run similar scripts and had no problems <?php include("include/configvb.inc.php"); $pics = mysql_query("SELECT * FROM picture"); while ($got_pics = mysql_fetch_array($pics)){ mysql_query("INSERT INTO albumpicture (`albumid`,`pictureid`) VALUES ('".$got_pics['userid']."','".$got_pics['pictureid']."')"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/166219-solved-weird-server-behaviour/ Share on other sites More sharing options...
rhodesa Posted July 16, 2009 Share Posted July 16, 2009 nope...not sure, but why wouldn't you just do this: INSERT INTO `albumpicture` (`albumid`,`pictureid`) SELECT (`userid`,`pictureid`) FROM picture no PHP loop needed Quote Link to comment https://forums.phpfreaks.com/topic/166219-solved-weird-server-behaviour/#findComment-876526 Share on other sites More sharing options...
JonnoTheDev Posted July 16, 2009 Share Posted July 16, 2009 Why do you need a script to do this. Also you do not need a loop. Read on MySQL insert select i.e. INSERT INTO albumpicture (albumid, pictureid) SELECT albumid, pictureid FROM picture Quote Link to comment https://forums.phpfreaks.com/topic/166219-solved-weird-server-behaviour/#findComment-876527 Share on other sites More sharing options...
ukscotth Posted July 16, 2009 Author Share Posted July 16, 2009 coz im a newbie lol but thanks so all i need to use is that single line yes ? Quote Link to comment https://forums.phpfreaks.com/topic/166219-solved-weird-server-behaviour/#findComment-876531 Share on other sites More sharing options...
rhodesa Posted July 16, 2009 Share Posted July 16, 2009 yup...just that one query, run once. and use the code by @neil.johnson, mine shouldn't have the extra parenthesis in the select portion Quote Link to comment https://forums.phpfreaks.com/topic/166219-solved-weird-server-behaviour/#findComment-876539 Share on other sites More sharing options...
JonnoTheDev Posted July 16, 2009 Share Posted July 16, 2009 Wouldn't run through a browser either. Straight into mysql server. Quote Link to comment https://forums.phpfreaks.com/topic/166219-solved-weird-server-behaviour/#findComment-876544 Share on other sites More sharing options...
ukscotth Posted July 16, 2009 Author Share Posted July 16, 2009 ok thanks very much, il give it a go now Quote Link to comment https://forums.phpfreaks.com/topic/166219-solved-weird-server-behaviour/#findComment-876547 Share on other sites More sharing options...
ukscotth Posted July 16, 2009 Author Share Posted July 16, 2009 thnx peeps, looks like its worked doing it that way Quote Link to comment https://forums.phpfreaks.com/topic/166219-solved-weird-server-behaviour/#findComment-876554 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.