computermax2328 Posted October 4, 2012 Share Posted October 4, 2012 Take a look at this really quick. I am not getting anything out of this query. All I am doing is echoing description which is saved as a text in a phpmyadmin database. 'table' is coming from the URL. The variable $table is working in other queries. $table = $_GET['table']; $issues = "SELECT * FROM issues WHERE table='$table'"; $isquery = mysql_query($issues, $connection); while ($row = mysql_fetch_array($isquery)) { $desc = $row['description']; } Thanks, Link to comment https://forums.phpfreaks.com/topic/269089-take-a-look-at-this-query-real-quick/ Share on other sites More sharing options...
Christian F. Posted October 4, 2012 Share Posted October 4, 2012 var_dump ($_GET); Also, you really need to validate input and escape your output. This script is wide open for any kind of attack, SQL and HTML (XSS) injection both. Link to comment https://forums.phpfreaks.com/topic/269089-take-a-look-at-this-query-real-quick/#findComment-1382744 Share on other sites More sharing options...
Barand Posted October 4, 2012 Share Posted October 4, 2012 Quote while ($row = mysql_fetch_array($isquery)) { $desc = $row['description']; } that doesn't echo anything! Link to comment https://forums.phpfreaks.com/topic/269089-take-a-look-at-this-query-real-quick/#findComment-1382746 Share on other sites More sharing options...
computermax2328 Posted October 5, 2012 Author Share Posted October 5, 2012 I echo it somewhere else. echo $desc; Link to comment https://forums.phpfreaks.com/topic/269089-take-a-look-at-this-query-real-quick/#findComment-1382764 Share on other sites More sharing options...
nodirtyrockstar Posted October 5, 2012 Share Posted October 5, 2012 Your variable ('$table') is in quotes. I don't know if that matters since I can't see the rest of your script. Also, have you tried plugging the query directly into MySQL? It helps to start with a good query, and then troubleshoot the PHP. Link to comment https://forums.phpfreaks.com/topic/269089-take-a-look-at-this-query-real-quick/#findComment-1382768 Share on other sites More sharing options...
Jessica Posted October 5, 2012 Share Posted October 5, 2012 You should always post your actual code, and the entire relevant part. Of course we're going to point out you don't echo it. If you're echo'ing it outside of the loop, that's probably a big part of the problem. Link to comment https://forums.phpfreaks.com/topic/269089-take-a-look-at-this-query-real-quick/#findComment-1382777 Share on other sites More sharing options...
computermax2328 Posted October 5, 2012 Author Share Posted October 5, 2012 Echoing inside the loop did not work. I echo outside the loop all the time and it works fine. I did the var_dumb and it can back null. Link to comment https://forums.phpfreaks.com/topic/269089-take-a-look-at-this-query-real-quick/#findComment-1382792 Share on other sites More sharing options...
Pikachu2000 Posted October 5, 2012 Share Posted October 5, 2012 If it won't echo inside the loop, and it won't echo outside the loop, what would that tell you? Maybe that the query isn't returning any results? Link to comment https://forums.phpfreaks.com/topic/269089-take-a-look-at-this-query-real-quick/#findComment-1382799 Share on other sites More sharing options...
Christian F. Posted October 5, 2012 Share Posted October 5, 2012 On 10/5/2012 at 3:42 AM, computermax2328 said: ...I did the var_dumb and it can back null. That means you're not sending any data to the page in the URL, which causes PHP to query for data where table = ''. Link to comment https://forums.phpfreaks.com/topic/269089-take-a-look-at-this-query-real-quick/#findComment-1382809 Share on other sites More sharing options...
White_Lily Posted October 5, 2012 Share Posted October 5, 2012 If the table is being found in the database try echoing the rows: $num = mysql_num_rows($issues); echo $num; If it echos nothing (not even a 0) then your query is probably the problem, if it echos '0' then its saying you have no entries, anything higher and the problem is elsewhere. Link to comment https://forums.phpfreaks.com/topic/269089-take-a-look-at-this-query-real-quick/#findComment-1382857 Share on other sites More sharing options...
computermax2328 Posted October 5, 2012 Author Share Posted October 5, 2012 Alright, so I did some tests, var_dumb, num_rows and some !if statements, and I found that the query is what is incorrect. The $_GET variable is coming down, but the query is not working. It stops at the fetch_array. Link to comment https://forums.phpfreaks.com/topic/269089-take-a-look-at-this-query-real-quick/#findComment-1382969 Share on other sites More sharing options...
Christian F. Posted October 5, 2012 Share Posted October 5, 2012 Then this is solved, or..? PS: It's "var_dump", not "b". Link to comment https://forums.phpfreaks.com/topic/269089-take-a-look-at-this-query-real-quick/#findComment-1382974 Share on other sites More sharing options...
computermax2328 Posted October 5, 2012 Author Share Posted October 5, 2012 Yeah that was a typo. I solved it. I will mark it so Link to comment https://forums.phpfreaks.com/topic/269089-take-a-look-at-this-query-real-quick/#findComment-1383020 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.