php function page for mysql_query("INSERT......)
I have a mySql INSERT statement with 11 columns on a page call "add_product.php". The statement is inside an 'else' clause on line 132. I want to write it on a separate function page so I may catch my sql mistake faster (not too long ago I inadvertently leave a comma before "WHERE" and mess up the whole thing) . I am a newbie to php and have no experience creating a separate function page. Please help me by giving me details as to how to move the query(INSERT...) statement to create a function.php page; and how to call that function into action on the "add_product.php" page - which I attach herewith. Thank you add-product.php
My aim is to learn how to make some codes portable and easier to debug. Since I easily mess up the sql code, and I agree in entirety to your earlier suggestion of keeping each name=value pair (and WHERE in the UPDATE page) on an individual line, that's why the question. I had attached the INSERT page, not the UPDATE page, as example because it was shorter. But to express myself better, let's post the UPDATE page now in snippet. the modular I want to move is the mysql_query("UPDATE products SET... on line 141:
Open in new window
My aim is to learn how to make some codes portable and easier to debug. Since I easily mess up the sql code, and I agree in entirety to your earlier suggestion of keeping each name=value pair (and WHERE in the UPDATE page) on an individual line, that's why the question. I had attached the INSERT page, not the UPDATE page, as example because it was shorter. But to express myself better, let's post the UPDATE page now in snippet. the modular I want to move is the mysql_query("UPDATE products SET... on line 141:
Open in new window
My apology for using a lot of layman php description. I'll keep learning to improve it.