Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8785263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:18:32+00:00 2026-06-13T21:18:32+00:00

I am currently working with mysql_connect() even though it’s use is discouraged. My web

  • 0

I am currently working with mysql_connect() even though it’s use is discouraged. My web service does not support PDO. I currently had my code formatted into PDO but now i have been forced to change it to mysяl_connect(). After these changes now I am receiving a page error and nothing displays. I am including a database_connect.php that is working with another page just not with my adapted code. What is the issue in my code that is causing this error? Here is my PAGE

Code

include ('./snippets/db_connect.php');

      $query = ("SELECT  class_name, class_caption, class_credit_hours, class_description
                 FROM class                          
                 ");
      $query->execute();

     if ($query->execute()){

    $totalhours = 0;

    while ($row = mysql_fetch_assoc( $query )){  
        print "<b>" . $row['class_name'] . "</b><br>";
        print $row['class_caption'] . "<br>";
        print $row['class_description'] . "<br>";
        print $row ['class_credit_hours'] . "hrs. <br>";

        print "------------------------------<br />";
        $totalhours += $row['class_credit_hours']; 
    }

    print "<p>Total hours for Major: " . $totalhours . ".</p>";

    "<div> </div>"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:18:34+00:00Added an answer on June 13, 2026 at 9:18 pm

    $query is jsut a string, so there is no execute method. You never call mysql_query($query). so there is no result set.

    $sql = "SELECT  class_name, class_caption, class_credit_hours, class_description FROM class"
    $result = mysql_query($sql);
    
    if($result) {
      while ($row = mysql_fetch_assoc($result)){
         /// do stuff
      }
    }
    

    Also if your host doesn’t support PDO you should switch, even if you arent planning on using it. There is no excuse for them not to support it at this point in time, it was made standard in php 5.1, and your host should at least have php 5.2.17 available if not the current stable of 5.3.

    Now, if you know PDO you might want to try Mysqli instead of ext/mysql. Its more like PDO and supports prepared statments and what not. Your host should at least have that. If they dont then double emphasis on changing hosting providers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The university servers I'm currently working on lack PDO drivers, hence I've had to
we are currently working on a new web application using Java and MySql. We
I am currently working on a clients web site and I ran into a
I have the following code, and it will not work. I am currently working
I'm working through Practical Web 2.0 Appications currently and have hit a bit of
I'm currently working on a PHP application that uses a MySQL database for its
I am currently working on a small sponsorship application(PHP/MySql) for my personal blog, and
Currently, I am working on the very beginnings of a user database in MySQL
I am currently working with a query in in MSSQL that looks like: SELECT
Currently working with converting SQLException error messages into messages that are more useful for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.