Error running mysql_query

Asked

Viewed 373 times

-4

This is my line 17 programming:

$result = mysql_query($localhost, "SELECT *FROM **nome do meu banco**") 
or die (mysql_error());

This is the mistake I can’t make:

Warning: mysql_query() expects Parameter 2 to be Resource, string Given in /home/u803520287/public_html/android/name of my bank.php on line 17

How to correct?

1 answer

3

Basically it’s a typo.

The PHP manual is clear in the order of the parameters:

mysql_query (string $query[, resource $link_identifier] )

More details:

http://php.net/manual/en/function.mysql-query.php

The suggestion is to change functions mysql for mysqli, which are not obsolete (and in this case, the link comes first in these).

See more here: Improved Mysql extension

  • Thank you very much for the help, I started 2 days doing programming and still have difficulty in understanding the data order. I did the update and gave 2 errors that follow. Warning: mysqli_query() expects Parameter 1 to be mysqli, null Given in /home/u803520287/public_html/android/Findme.php on line 17 Warning: mysqli_error() expects Exactly 1 Parameter, 0 Given in /home/u803520287/public_html/android/Findme.php line 17 as should be the line I posted?

  • These two errors you can locate by searching the site: http://answall.com/search?q=expects+parameter+1+to+be+mysqli and the second is the missing link of the connection in the parentheses mysqli_error( $sua_conexao);. Do a little mysqli search that has several examples on the site and in the manual http://php.net/manual/en/book.mysqli.php

Browser other questions tagged

You are not signed in. Login or sign up in order to post.