How fix php error?

Discussion in 'PHP' started by talker1, Oct 28, 2012.

  1. #1
    PHP Warning: mysql_query() expects at most 2 parameters, 3 given

    PHP Warning: mysql_fetch_array() expects parameter 1 to be resource, null given


    line create error:

    	$Result = mysql_query($_VAR['MYSQL']['DBNAME'], $query, $link);
    	while($Row = mysql_fetch_array($Result))
    PHP:

    Thank you.
     
    talker1, Oct 28, 2012 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #2
    mysql_query ( string $query [, resource $link_identifier = NULL ] )

    So it takes the query as the first argument and the identifier of the database as the second argument.
    First connect to the database. Then select the db. Then you can do your query.
    Try


    $Result = mysql_query($query);

    (Note: the mysql functions won't be supported in future versions. Start learning mysqli or PDO.)
     
    Rukbat, Oct 28, 2012 IP