-3

I got this message

Warning: mysql_query() expects parameter 1 to be string, object given in

In regard to this line:

$QSelPro = mysql_query($con,"SELECT * FROM products");

what's wrong with this????

Mark Miller
  • 7,442
  • 2
  • 15
  • 21
user3620028
  • 3
  • 1
  • 4
  • 5
    duplicate of 10 million other questions –  Jun 06 '14 at 02:43
  • Location-Location-Location – Funk Forty Niner Jun 06 '14 at 02:44
  • 1
    Have a look at the [argument order for that function](http://us2.php.net/mysql_query). While you are at it, take a look at the big block of text with the red background titled **Warning**. – Crackertastic Jun 06 '14 at 02:46
  • @Dagon Is this really a duplicate of the question specified? The two questions, as well as their solutions, are entirely different. I agree, this question is not new, but perhaps a better duplicate could be found? – Mark Miller Jun 06 '14 at 03:14
  • i picked the first duplicate i could, any one else can vote for another duplicate if they like (well not any more) the others where as lazy as me for not checking properly –  Jun 06 '14 at 03:31
  • @dagon I'm not sure how it works exactly, if there is a way to dispute the duplicate thing or not. No biggy, though. I edited the question to clarify my point but maybe it's too late. Oh well. – Mark Miller Jun 06 '14 at 03:36

1 Answers1

2

From the PHP manual for mysql_query():

mixed mysql_query ( string $query [, resource $link_identifier = NULL ] )

Thus, change to

$QSelPro = mysql_query("SELECT * FROM products", $con);

Also from the same page:

Warning
This extension is deprecated as of PHP 5.5.0, and will be removed in the future...

In other words, consider not using mysql_*. It is deprecated. Instead use mysqli_* or pdo

Mark Miller
  • 7,442
  • 2
  • 15
  • 21
  • so what's the differences between "mysql_" and "mysqli_"? – user3620028 Jun 06 '14 at 06:54
  • @user3620028 The 'i' in `mysqli` stands for 'improved'. Read more [**here**](http://php.net/manual/en/mysqli.overview.php) and [**here**](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) – Mark Miller Jun 06 '14 at 07:02