I'm trying to introduce a $variable inside a MySQL query.
In a previous thread: :
1-sleipnir214 suggested the usage of a global variable, and provided a link with inclusions of the global var into normal functions().
2-LTeeple suggested concatenating the variable outside of the SQL Instruction.
I've tried both methods and so far I've had no success. Where within the MySQL query do you place the global var without altering it?
As for the concatenation, My SQL instruction is longer so using concatenation results in instrunction-concatenated var-instruction, which returns an error.
Here is my Query along with the defined var on top:
In a previous thread: :
1-sleipnir214 suggested the usage of a global variable, and provided a link with inclusions of the global var into normal functions().
2-LTeeple suggested concatenating the variable outside of the SQL Instruction.
I've tried both methods and so far I've had no success. Where within the MySQL query do you place the global var without altering it?
As for the concatenation, My SQL instruction is longer so using concatenation results in instrunction-concatenated var-instruction, which returns an error.
Here is my Query along with the defined var on top:
Code:
// Var definition, Value comes from the an URL variable "tipo"
$tipo = $_GET['tipo'];
// Query with the inclusion of $tipo inside the SQL instruction
mysql_select_db($database_conn_siitto, $conn_siitto);
$query_lista_main = sprintf("SELECT * FROM tbl_montac, tbl_marca WHERE tbl_marca.marca_ID = tbl_montac.marca AND tipo = $tipo ORDER BY mont_ID ASC", GetSQLValueString($colname_lista_main, "int"));
$lista_main = mysql_query($query_lista_main, $conn_siitto) or die(mysql_error());
$row_lista_main = mysql_fetch_assoc($lista_main);
$totalRows_lista_main = mysql_num_rows($lista_main);