Page 1 of 1

Error in script

Posted: Tue Jul 22, 2003 7:28 am
by tuta
Hi!!!
I Have one SQL in my script. And the result this SQL return 0 rows. But i have fields in my DataBase with this condition.
Maybe i error in SQL sintaxe.
Help me please!!!
The script is this:
$res = mysql_connect("localhost","escola");
if ($res)
{
$colocar = $_POST["D1"];
$sql = "Select * from Cursos Where DesCurso like('$colocar%') ";
$result = Mysql_db_query("escola","$sql",$res);
echo mysql_num_rows($result);
while ($present = mysql_fetch_array($result))
{
if ($present["DesCurso"] = $colocar)
{
$valor = $present["ValCurso"];
$quant = $present["ParCurso"];
echo $present["DesCurso"];
}
}

}

I´m try too this SQL:
$sql = "Select * from Cursos Where DesCurso = $colocar";
And nothing.

Thank´s

Miguel

Posted: Tue Jul 22, 2003 7:33 am
by m@ndio
what is the escola bit??

$result = Mysql_db_query(">>escola<<","$sql",$res);

Posted: Tue Jul 22, 2003 7:34 am
by tuta
escola is my DataBase name.

Posted: Tue Jul 22, 2003 9:09 am
by tuta
I solution this problem with trim() function.
Thnak´s
Miguel

Posted: Tue Jul 22, 2003 9:33 am
by kafka_loved_his_daddy
hello.

you may try

Code: Select all

mysql_select_db("escola");
and

Code: Select all

mysql_query($sql, $res);
instead of mysql_db_query. once I had a similar problem. using the newer functions (mysql_db_query seems to be deprecated) worked fine.

cheers
marcel