Results 1 to 3 of 3

Thread: Cannot read information from mySQL database (using PHP)

  1. #1
    icanguessit is offline Junior Member
    Join Date
    Jun 2014
    Posts
    2

    Unhappy Cannot read information from mySQL database (using PHP)

    I have looked through the forum boards, and while this seems like a very routine problem, I can't seem to find anything addressing my issue. I have created a php page which is meant to read and write responses to a database that I created using phpMyAdmin. I am using the following PHP code to connect to my database and return the number of rows of data entered, but it returns with 0 rows of data. I verified that the database_name and table_name was correct that I attempted to read from and that there are indeed 3 rows of data manually entered into the database via phpMyAdmin. Is there something wrong with how I am connecting, or my SELECT statement? Thank you so much if you can help me! By the way, my PHP page loads fine, everything is good except I cannot echo anything from mySQL database.

    PHP Code:
    $host="localhost";
    $user="icanguessit";
    $password = "****"; //*'s represent actual password used
    $myconn=mysql_connect($host,$user,$password) or die("Connection error");
    $db_name="my_icanguessit";
    mysql_select_db($db_name,$myconn);
    $query_read="SELECT * FROM 'people'";
    $result=mysql_query($query_read,$myconn);
    $row_number=mysql_num_rows($result);
    echo
    "testing: num rows = ".$row_number;

  2. #2
    Gianluca is offline Administrator
    Join Date
    Feb 2010
    Posts
    512

    Default

    You should print the output of mysql_error() in order to understand what is going wrong.

  3. #3
    icanguessit is offline Junior Member
    Join Date
    Jun 2014
    Posts
    2

    Smile error around the 'people'

    Quote Originally Posted by Gianluca View Post
    You should print the output of mysql_error() in order to understand what is going wrong.
    Thanks a bunch, I had no idea how to troubleshoot this problem as there was no error printing on the php page. With that said, after echoing mysql_error(), the error message pointed me directly to my problem($query_read="SELECT * FROM 'people'", dd not need the single quotes around people). Again, thank you for your time, my page will be up in no time now.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

SEO by vBSEO