Help me with this error please

Discussion in 'PHP' started by romioaa, Aug 13, 2011.

  1. #1
    I am getting the following error:

    
    Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in C:\wamp\www\accounting\members.php on line 10
    
    HTML:
    This is the code: The connection to the database is working

    
    <?php include_once 'include/mysql.php';?>
    
    <?php
    echo "Welcome to the Memebers Area";
    
    
    
    $result1 = mysql_query("SELECT * FROM trans, $connection");
    
    while($row1 = mysql_fetch_array('$result1'))
      {
          echo $row1['product_name'];
      
      }
      
      
    mysql_close()
    
    ?> 
    
    PHP:
     
    romioaa, Aug 13, 2011 IP
  2. rainborick

    rainborick Well-Known Member

    Messages:
    424
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    120
    #2
    Remove the single quotes around $result1.

    
    while($row1 = mysql_fetch_array($result1))
    
    PHP:
     
    rainborick, Aug 13, 2011 IP
  3. Mariebradley

    Mariebradley Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks @rainborick
    Your solution work perfectly.
    Also remember for the coder should remember about the quotes it's two types ("),(') if you using single into the php tag you should use the double in html so you code wouldn't be broken.
     
    Mariebradley, Aug 13, 2011 IP
  4. JohnnySchultz

    JohnnySchultz Peon

    Messages:
    277
    Likes Received:
    4
    Best Answers:
    7
    Trophy Points:
    0
    #4
    in PHP, variables are parsed inside double quotes ("), inside single quotes it doesn't because it will be treated as a normal string.
     
    JohnnySchultz, Aug 15, 2011 IP