mysql_fetch_array() not a valid MySQL

Discussion in 'PHP' started by gilgalbiblewheel, Dec 13, 2007.

  1. #1
    What do I use instead of this?

     
    gilgalbiblewheel, Dec 13, 2007 IP
  2. ForgottenCreature

    ForgottenCreature Notable Member

    Messages:
    7,473
    Likes Received:
    173
    Best Answers:
    0
    Trophy Points:
    260
    #2
    Post the code here.
     
    ForgottenCreature, Dec 13, 2007 IP
  3. gilgalbiblewheel

    gilgalbiblewheel Well-Known Member

    Messages:
    435
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #3
    Ok. Within the page I put INSERT and SELECT.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <?php
        require_once('mysql.php');
    /*$query = "INSERT INTO book (ft0, ft1, ft2, ft3, ft4) VALUES ('$FirstName', '$LastName', '$PhoneNumber')";*/
    
    ?>
    
    <?php
     
    //some stuff up here
     
    //check to make sure field has value
    /*if(empty($_POST['ft0']) {
    echo 'You must fill in the textarea!';
    die();
    }
    
    
    $i = 1;
    mysql_query('INSERT INTO book (ft0) VALUES ("'.mysql_real_escape_string($_REQUEST["ft0".$i]).'")');
    */
    
    
    mysql_select_db("satb", $con);
    
    for ($i=1; $i<=30; $i++)
    {
    	$sql="INSERT INTO book (line)
    	VALUES
    	('$_POST[line15]')";
    }
    
    if (!mysql_query($sql,$con))
      {
      die('Error: ' . mysql_error());
      }
    echo "1 record added";
    
    mysql_close($con);
    
    
    $con = mysql_connect("","root","");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    // some code
    
    $result = mysql_query("SELECT line FROM book");
    	//$sql2 = "SELECT line FROM book";
    	echo "<br />" .$result;
    	
    while($row = mysql_fetch_array($result))//line 61
      {
      echo $row['line'];
      echo "<br />";
      }	
     
    ?>
    </body>
    </html>
    
    PHP:
     
    gilgalbiblewheel, Dec 13, 2007 IP
  4. sunnyverma1984

    sunnyverma1984 Well-Known Member

    Messages:
    342
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    120
    #4
    check your mysql table 'book' does it have 'line' field
     
    sunnyverma1984, Dec 14, 2007 IP
  5. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #5
    Replace:
    
    $result = mysql_query("SELECT line FROM book");
    
    PHP:
    With:
    
    $result = mysql_query("SELECT line FROM book") OR die(mysql_error());
    
    PHP:
    And tell me what error you get.
     
    nico_swd, Dec 14, 2007 IP