+ 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?

3rd Apr 2017, 4:00 PM
Fausto Gutman
Fausto Gutman - avatar
4 Respuestas
+ 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");
3rd Apr 2017, 4:18 PM
Ani Naslyan
Ani Naslyan - avatar
0
i did all right even if I write $post="Select * from table_name"; it works. but when $post=_Post['query']; isnt work
3rd Apr 2017, 5:06 PM
Fausto Gutman
Fausto Gutman - avatar
0
also i put echo $post and the echo works pefectly
3rd Apr 2017, 5:08 PM
Fausto Gutman
Fausto Gutman - avatar
0
Because you are not using end brackets like for example if you wrote this:<$result=$conn->query($sql);>
5th Apr 2017, 4:57 PM
zayah
zayah - avatar