sql >> Database >  >> RDS >> Mysql

mySQL-query meerdere - retourneert fout mysql_fetch_array

Je vergeet mysql_query , wijzigen:

// Select database
mysql_select_db("teste") or die(mysql_error());

// Get data from the database

$strSQL = "SELECT id_quarto,tipo_quarto,vista_quarto FROM quartos,reservas WHERE quartos.id_quarto!=reservas.id_quarto AND quartos.tipo_quarto='". $_POST['tipo_quarto'] ."' AND quartos.vista_quarto='". $_POST['vista_quarto'] ."'";

// Loop the recordset $rs
// Each row will be made into an array ($row) using mysql_fetch_array
while($row = mysql_fetch_array($rs)) {

naar:

// Select database
mysql_select_db("teste") or die(mysql_error());

// Get data from the database

$strSQL = "SELECT q.id_quarto, q.tipo_quarto, q.vista_quarto ".
          " FROM quartos q, reservas r".
          " WHERE q.id_quarto != r.id_quarto ".
          " AND q.tipo_quarto = '". mysql_real_escape_string($_POST['tipo_quarto']) ."' ".
          " AND q.vista_quarto = '". mysql_real_escape_string($_POST['vista_quarto']) ."'";

$rs = mysql_query($strSQL);

// Loop the recordset $rs
// Each row will be made into an array ($row) using mysql_fetch_array
while($row = mysql_fetch_array($rs)) {

Toegevoegd :Voorkom SQL-injectie met mysql_real_escape_string op elke parameter van de gebruiker.



  1. alternatief voor listagg in Oracle?

  2. Bestanden uploaden en downloaden PHP en MySQL

  3. MySQL #1140 - Mengen van GROEP-kolommen

  4. Waarom verbreken Hibernate/JDBC/MySQL verbindingen na een dag of zo?