|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Am trying to have a code that executes any Select and Insert query to any table and echoes the results.Am new to programming so plz excuse my dumb errors
Please test and complete this code for me. Thanks PHP Code:
|
|
#2
|
||||
|
||||
|
Your main problem is probably that you're suppressing errors in your call to mysql_query(). That's what the "@" does. Remove that and add a die statement afterward as you've done above. To make your die statement more meaningful, try "die(mysql_error())" to get the actual mysql error. Also, you've got a weird $ after your echo. Dump that. Also, this shouldn't cause an error, but consider using $_POST rather than $HTTP_POST_VARS. It's easier to type in addition to being more up to date.
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
|
#3
|
|||
|
|||
|
ok.here is what i come with.But queries passed with single or double quote are not working. the following \ is added before each double quote.Any way to solve that?
PHP Code:
|
|
#4
|
||||
|
||||
|
What error do they come back with? You probably just need to wrap addslashes() around the query to escape quotes.
Incidentally, it's a very bad idea to allow people to post arbitrary queries to be executed. Imagine somebody guesses (correctly) that you've got a table named "users" and they send the query "DELETE FROM users." |
|
#5
|
|||
|
|||
|
I think its the contrary that needs to be done.I am passing a query not the data that needs to be inserted in the DB.
If i use the addslashes function the the query us again modified and added a slash for every quote.. How to preserve the query with its quotes? Error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '\"nm\"' at line 1 |
|
#6
|
|||
|
|||
|
LOL
the contrary: stripslashes() dhouston thanks for putting me on the path ![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > php code for executing any select and insert query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|