vinpkl Posted June 18, 2009 Share Posted June 18, 2009 hi all i have a field name "detail_description" in my product_table on number 5. i have a field name "product_image" in my product_table on number 11. i want to interchange them and want to move "detail_description" field to number 11 and product_image field to number 5. As some data has been already been added to the database so i dont want to spoil my data. how can i do it safely vineet Quote Link to comment https://forums.phpfreaks.com/topic/162725-interchange-fields-place-in-phpmyadmin/ Share on other sites More sharing options...
J.Daniels Posted June 18, 2009 Share Posted June 18, 2009 There shouldn't be a need to 'reorder' the fields of a table, as relational databases are based on sets, which have no order. If you are using mysql_fetch_row(), then rows are returned in a numbered array. I can see why you might want to change the 'order' of the fields, but why not change the code instead of the database? You can use mysql_fetch_assoc(), which will return the rows as an associative array, and you can access the fields by name. Quote Link to comment https://forums.phpfreaks.com/topic/162725-interchange-fields-place-in-phpmyadmin/#findComment-859132 Share on other sites More sharing options...
vinpkl Posted June 19, 2009 Author Share Posted June 19, 2009 hi daniel As i m using FCKeditor and image upload fields, so i wanted to upload image before fckeditor content. At present this code uploads the image after fckeditor and the image sometimes get missed somewhere and i have to upload it again. I dont know may be because of the heaviness of fckeditor content, the script times out or what happens but sometimes image misses out. My below code is according to sequence of fields in database. If i add the products according to this sequence then the product gets added successfully but sometimes image misses out and if i change the sequence of fields in this code then i get error. Like if i add 10 products then the 7 times the product get uploaded completely and 3 times the image misses out. $insertqry="insert into product_table(product_date, category_id, dealer_id, product_name, category_name, description, detail_description, cutout_price, price, image, shipping_cost, shipping_detail,warranty,sub_catg) values('$product_date',$catid,$dealerid,'$prod_name','$category_name','$prod_desc', '$prod_descbig', $prod_cutprice, $prod_price, '$path',$prod_ship,'$shipping_detail','$warranty','$sub_catg')"; Does this happen to everyone who changes the sequence of fields or is there any solution. Do you know any light version of fckeditor. vineet Quote Link to comment https://forums.phpfreaks.com/topic/162725-interchange-fields-place-in-phpmyadmin/#findComment-859354 Share on other sites More sharing options...
J.Daniels Posted June 19, 2009 Share Posted June 19, 2009 You can enter data into the database in any order. For example: INSERT INTO table (table1, table2) VALUES ('table1value', 'table2value'); is the same as: INSERT INTO table (table2, table1) VALUES ('table2value', 'table1value'); What I would be focusing on is what is causing the script to timeout or fail. ie. which out of the 10 records is failing and why Quote Link to comment https://forums.phpfreaks.com/topic/162725-interchange-fields-place-in-phpmyadmin/#findComment-859804 Share on other sites More sharing options...
EchoFool Posted June 20, 2009 Share Posted June 20, 2009 put an or die(mysql_error()); after queries they will display any errors that occured in the query which otherwise wouldn't display: <?php $insertqry= mysql_query("insert into product_table(product_date, category_id, dealer_id, product_name, category_name, description, detail_description, cutout_price, price, image, shipping_cost, shipping_detail,warranty,sub_catg) values('$product_date',$catid,$dealerid,'$prod_name','$category_name','$prod_desc', '$prod_descbig', $prod_cutprice, $prod_price, '$path',$prod_ship,'$shipping_detail','$warranty','$sub_catg')") or die(mysql_error()); ?> Then post back any error your given. Also why are some $variables in ' ' symbols and others not ? Quote Link to comment https://forums.phpfreaks.com/topic/162725-interchange-fields-place-in-phpmyadmin/#findComment-859980 Share on other sites More sharing options...
vinpkl Posted June 20, 2009 Author Share Posted June 20, 2009 hi echofool i will surely post back the exact error i get while adding product. secondly Some $variables are within ' ' symbols because they are not integers or simply i can say they are not numeric values thats why are within these ' ' symbols. vineet Quote Link to comment https://forums.phpfreaks.com/topic/162725-interchange-fields-place-in-phpmyadmin/#findComment-859996 Share on other sites More sharing options...
fenway Posted June 22, 2009 Share Posted June 22, 2009 Just FYI, you can move the fields around, but as indicated by others, unless you're actually browsing the tables from an IDE, it doesn't really matter. Quote Link to comment https://forums.phpfreaks.com/topic/162725-interchange-fields-place-in-phpmyadmin/#findComment-860982 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.