Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/268152-php-query-mysql-db-problem/
Share on other sites

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.

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.)

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.