0

I come across with various type of format, here are them

mysqli_query($con,"UPDATE Persons SET Age=36
WHERE FirstName='Peter' AND LastName='Griffin'");

and

SELECT ALL FROM users WHERE user_id=:user_id

..and about mysql_query, it works without the $con parameter, explain? thanks

  • The second query is a prepared statement with PDO. And yes, `mysql_query` works without the addition parameter. But you should really be looking at PDO/mysqli since `mysql_*` is depreciated. – Ben Fortune Sep 20 '13 at 09:27
  • The second select statement is using a prepared statement and bind variables; something that it will be very useful for you to learn about as it's highly recommended to protect your application against SQL injection attacks – Mark Baker Sep 20 '13 at 09:27

2 Answers2

1

it works without the $con parameter, explain?

The former code is MySQLi and the latter is a PDO Statement.

Getting started with MySQLi
Getting started with PDO

PDO vs MySQLi

Community
  • 1
  • 1
Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126
0

mysql_query detects the last connection to a database.