Error in script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tuta
Forum Newbie
Posts: 21
Joined: Mon Jun 30, 2003 3:37 pm
Location: Brasil

Error in script

Post 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
User avatar
m@ndio
Forum Regular
Posts: 163
Joined: Fri Jun 06, 2003 12:09 pm
Location: UK

Post by m@ndio »

what is the escola bit??

$result = Mysql_db_query(">>escola<<","$sql",$res);
tuta
Forum Newbie
Posts: 21
Joined: Mon Jun 30, 2003 3:37 pm
Location: Brasil

Post by tuta »

escola is my DataBase name.
tuta
Forum Newbie
Posts: 21
Joined: Mon Jun 30, 2003 3:37 pm
Location: Brasil

Post by tuta »

I solution this problem with trim() function.
Thnak´s
Miguel
kafka_loved_his_daddy
Forum Newbie
Posts: 3
Joined: Tue Jul 22, 2003 3:06 am
Location: austria

Post 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
Post Reply