xeloris Posted September 8, 2012 Share Posted September 8, 2012 Hey guys, Im new to the dev scene trying to learn some php. However after many hours i cannot figure it out.. I am having problems querying data from the mysql database... Here is what i have... I go into phpmysql the query statement works, so i know that there is nothing wrong with the database. Here is some code could someone please help.. It would be greatly appreciated!!! Thanks in advance. Attached is the php doc 18993_.php Quote Link to comment https://forums.phpfreaks.com/topic/268152-php-query-mysql-db-problem/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 8, 2012 Share Posted September 8, 2012 Your code is making a database connection after trying to execute a mysql_query() statement. You need to have php's error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that php will help you by reporting and displaying all the errors it detects. You will save a TON of time. Stop and start your web server to get any changes made to the master php.ini to take effect and check using a phpinfo statement that the two settings actually got changed in case the php.ini that php is using is not the one that you changed. Quote Link to comment https://forums.phpfreaks.com/topic/268152-php-query-mysql-db-problem/#findComment-1376309 Share on other sites More sharing options...
xeloris Posted September 8, 2012 Author Share Posted September 8, 2012 Thanks! thats good information to know Quote Link to comment https://forums.phpfreaks.com/topic/268152-php-query-mysql-db-problem/#findComment-1376336 Share on other sites More sharing options...
xeloris Posted September 8, 2012 Author Share Posted September 8, 2012 Thanks for the response, I've turned on error reporting as suggested (thanks for that tip by the way).. Also i moved the OpenDB at the start of the php script before the query statement, It still does not query anything from the database.. Quote Link to comment https://forums.phpfreaks.com/topic/268152-php-query-mysql-db-problem/#findComment-1376359 Share on other sites More sharing options...
xeloris Posted September 8, 2012 Author Share Posted September 8, 2012 Is there a way to see if MYSQL DB is even receiving this query? Quote Link to comment https://forums.phpfreaks.com/topic/268152-php-query-mysql-db-problem/#findComment-1376368 Share on other sites More sharing options...
xeloris Posted September 9, 2012 Author Share Posted September 9, 2012 Found out how.. Appears that the query is making it to the database 0908 20:02:43 53 Connect root@localhost on 53 Init DB GWIMAIT 53 Query SELECT * FROM TEST 53 Quit Quote Link to comment https://forums.phpfreaks.com/topic/268152-php-query-mysql-db-problem/#findComment-1376369 Share on other sites More sharing options...
PFMaBiSmAd Posted September 9, 2012 Share Posted September 9, 2012 Your code has a do/while loop that it is deliberately running just once to output the table heading. There's no point in using any kind of loop around that table heading code since you would only want to output the table heading once. The while loop you kind of have around your code that displays the data from the query isn't constructed right. A while loop is - while(conditional statement){ statements that are executed inside the loop; ... } The {} delimit the code 'inside' the loop (yes, there's a special case with only one statement not needing the {}, but don't get in the habit of using php's lazy-way coding style) and there is no ; after the while(); (the one you have on the end of the while(); is actually terminating the while() loop on the line it is defined on.) Quote Link to comment https://forums.phpfreaks.com/topic/268152-php-query-mysql-db-problem/#findComment-1376436 Share on other sites More sharing options...
xeloris Posted September 9, 2012 Author Share Posted September 9, 2012 It worked!!!! Thanks for taking the the to help out with that.. Quote Link to comment https://forums.phpfreaks.com/topic/268152-php-query-mysql-db-problem/#findComment-1376438 Share on other sites More sharing options...
PFMaBiSmAd Posted September 9, 2012 Share Posted September 9, 2012 Upon further review of your code, you are also missing the {} for the if(isset($_POST['search'])&&!empty($_POST['search'])){... ...} statement. Edit: And your html markup needs help. You are outputting multiple <html></html> tags (there's only one set per page) and you don't have all the content in the page inside of the one set of <html> ... ... </html> tags. Quote Link to comment https://forums.phpfreaks.com/topic/268152-php-query-mysql-db-problem/#findComment-1376439 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.