0

I just simply want to execute a SQL sentence inside of a post (i am using EXEC-PHP widget for that).

The problem are the quotes when i want to do something like

$my_name='hello'

"select * from Table where name='$my_name'";

getting wrong quotes.... select * from Table where name=‘hello‘

i have tried streepslashes_deep, addslashes, stripslashes...

I think it shouldnt be so difficult... maybe its not my best day

any help?

thanks!

1

if you're communicating with the WordPress database itself, try using $wpdb->prepare() on your select string before running it as $wpdb->query() - it should format it for you.

Further reading: Codex

0

Perhaps the plugin is modifying your single quotes. Double quotes are valid in SQL. What happens if you use double quotes and escape them?

e.g. "select * from Table where name=\"$my_name\"";

0

Try seperating and concatenating stringss:

'select * from Table where name="'.$my_name.'"'; 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.