Question:
Whats wrong with this mysql query?
Ken W
2008-05-16 13:18:04 UTC
its connecting to the database all fine, but its not displaying anything in the database is there something wrong:

my fields are Id, and content

$query = "SELECT Id, content FROM main_page ORDER BY Id";
$result = mysql_query($query) or die('Error : ' . mysql_error());

while($row = mysql_fetch_array($result, MYSQL_NUM))
{
list($Id, $title) = $row;
$content .= "
  • $title
  • \r\n";
    }



    database connection coding:

    $username = "root";
    $password = "";
    $hostname = "localhost";

    $con = mysql_connect($hostname,$username,$password) or die ("Unable to connect");

    $dbname = 'banknorth';
    mysql_select_db($dbname);
    ?>

    help!! haha i dont have an error to go by its just not displaying anything
    Three answers:
    Pat
    2008-05-16 13:28:28 UTC
    Use the MySQL command line interface and hand-type the SQL query you're creating. My hunch is that there are zero rows that meet the criteria. You don't do any checking to see if the row count result is > 0.
    anonymous
    2016-10-13 04:48:33 UTC
    i think of greater records is mandatory from an blunders log. yet listed under are some issues to learn: a million) If the table has a prevalent and/or unique index on it, are you a) violating this distinctiveness, and b) no longer getting the blunders? to learn, see that the txt and course fee you are attempting to insert would not exist already interior the table. 2) are there different required fields you at the instant are not specifying? 3) The text fabric values in txt and course might desire to be embedded in rates. while the strings are resolved by potential of own domicile page, that's what's despatched to MySQL: insert into table values( ABC, DEF ) and what you probable prefer is this: insert into table values( "ABC", "DEF" ) 4) You point out that no longer the full code is right here. now and back, that's nice for brevity. yet according to possibility are you able to coach what your connect merchandise looke like? i'm questioning if may be you engaged a transaction which you probably did no longer commit (so it implicitly rolled back?)
    ?
    2008-05-16 13:49:09 UTC
    while loop sees a null value in $row, thus no record appears. Type some records in the database and then run this query. Ensure you have the indexed, primary key in the table structure.


    This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
    Loading...