Jump to content

mysql query- 2 questions


HoTDaWg

Recommended Posts

just to double check you can simply do:

<?php
mysql_query($sql,$connection);
//rather than
$results = mysql_query($sql,$connection);
?>

at the same time, a user on the php manual wrote this under comments regarding mysql_query:

It says in the manual:

 

The query string should not end with a semicolon.

 

However, I read somewhere that it is good practice to add a semicolon at the end of your query, and that it increases security against SQL-injection attacks. Therefore I have issued a requirement that all my developers end queries with semicolons.

 

So far, PHP & MySQL have happily accepted those queries, with only one exception:

 

If you use more then one query in the same call to mysql_query, MySQL sometimes only executes the first query and fails on the others.

so, should i end my mysql_queries with a ; or should i not ??? is there some sort of alternate method.

 

thanks for any help possible,

 

.-=!HoTDaWg!=-.

Link to comment
https://forums.phpfreaks.com/topic/45038-mysql-query-2-questions/
Share on other sites

by not using ; I think he means inside the query...

 

use

SELECT * FROM table

not

SELECT * FROM table;

 

as for your first question...

 

yes you can technically do

mysql_query($sql,$connection);

but you're not assigning the resource to any variables so you can't use it...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.