+ 2
I need help from a very experimented programer. I need a form that lets to the web visitor make all query he wants on my db
php an mysqli i made a web site and I shown a table with expecifit data. but I wanna give the option to change this table by writting your own query. in order to this I have used a form with a post method but its no works. it is like this: <form action="queries.php" . <input type="text" placeholder="write your query here" name="query" /> .. on query php I wrote: <?PHP $post=$_POST['query']; $sql=$post; $result=$conn->query($sql); .. I cant understand why $result still empty. can someone help?
4 Réponses
+ 3
Have you written something in $conn variable? It must include data like this:
$conn = mysqli_connect("host_name","user_name","password","database_name");
e.g.
$conn = mysqli_connect("localhost","root","usbw","registration");
After this you should choose your table name:
e.g.
mysql_select_db("data");
0
i did all right
even if I write
$post="Select * from table_name";
it works.
but when $post=_Post['query'];
isnt work
0
also i put echo $post and the echo works pefectly
0
Because you are not using end brackets like for example if you wrote this:<$result=$conn->query($sql);>