last day (15 days later) » 

8:54 PM
1
A: Getting table doesnt exist with php and mysql

D4V1DHere is your corrected code: $query = 'SELECT * FROM station_tab '; // note the space at the end if (!empty($_POST['station_name']) && !empty($_POST['city']) && !empty($_POST['zone'])) { $query .= ' WHERE station_name = ' .mysql_real_escape_string($_POST['station_name']) . ' AND city...

 
Can I ask why is that space so important? and thank guys I have moved for now. edit now I see why it is important.
 
Because concatenation just merges two strings. If you don't add a space, the words will be sticked with each others, resulting in a typo mistake.
 
now it echo error Unknown column 'my input' in 'where clause'
 
Where does 'my input' comes from?
 
<td><input type="text" name="city" /></td> this is where I am adding name of the city. So if I add Brno error will be Unknown column 'Brno' in 'where clause'
 
8:54 PM
You need to add the = sign in all your $query .= statements.
 
$query .== like this?
 
Just edited my answer with your complete corrected code.
 
still same error
 
The error being? What does var_dump($query); outputs?
Hi
 
Hi if I add var_dump it echo
NULL Unknown column 'Brno' in 'where clause'
 
8:56 PM
Do your var_dump($query); before $result =
 
NULL string(46) "SELECT * FROM station_tab WHERE city = Brno" Unknown column 'Presov' in 'where clause'
here it is
 
Where does Presov comes from?
Presov is not even in the query apparently. Is there something you're not telling me?
 
i have written presov now, brno was before ...
 
Right, you may need to add surrounding quotes (") for your values in your WHERE clauses.
I have edited my answer
 
ok I load page again. added for search Presov
Notice: Undefined variable: query in C:\xampp\htdocs\skola\hladanie.php on line 39
NULL string(46) "SELECT * FROM station_tab WHERE city = Presov" Unknown column 'Presov' in 'where clause'
 
9:01 PM
Why is $query undefined? Where do you put the var_dump() ?
 
before result
 
Sorry but I don't have enough info to help you further :/
 
query is undefined at the begining
 
That's normal
 
but on line 39 i have nothing ...
 
9:04 PM
Is line 39 the end of your file?
 
<?php
//line 39
if (isset($_POST['submit'])) {
at the beggining
I have put it away and now this
string(46) "SELECT * FROM station_tab WHERE city = Presov" Unknown column 'Presov' in 'where clause'
 
Don't put your var_dump($query) before assigning $query to something.
I have edited my answer with a newly corrected code. Give it a try.
(added the wrapping quotes)
 
same error
string(46) "SELECT * FROM station_tab WHERE city = Presov" Unknown column 'Presov' in 'where clause'
 
Are you sure you are using my new code? I have added the quotes and they are not appearing.
 
string(48) "SELECT * FROM station_tab WHERE city = "Presov""
this is what it output now so i should work Thanks!
 
9:16 PM
You're welcome. Please feel free to also up-vote my answer if I provided you with the needed help :)
 
I have already up voted :)
 
No worries :)
Happy coding!
See ya
 
bye
 

last day (15 days later) »