Page 1 of 1
connectivty error
Posted: Tue Aug 18, 2009 6:01 am
by yasir_memon
i am using oracle database with odbc connection but it runs only else condition either i give right user name and password kindly check this coding and tell me what kind is mistake i am doing
thanks in advance
<?php
$A=$_POST["text1"];
$B=$_POST["text2"];
$conn=odbc_connect('AKTMAPP','ERP_TEST','ERP_TEST');
$sql="SELECT * FROM USERS WHERE USR_NAME='$A' and PASSWORD='$B'";
$rs=odbc_exec($conn,$sql);
if(odbc_fetch_row($rs)>0)
{
header("Location:
http://index.php");
}
else
{
echo "error";
}
odbc_close($conn);
?>
Re: connectivty error
Posted: Tue Aug 18, 2009 6:19 am
by jackpf
Try putting "or odbc_errormsg()" after connections and queries. Also, turn error reporting on full.
Re: connectivty error
Posted: Tue Aug 18, 2009 6:22 am
by yasir_memon
i think there is no any connection error because when i am reteving record form table it shows be select statement , i think there is any error in logic so kindly tell me what is this i am using this on login page og my project??
thanks
Re: connectivty error
Posted: Tue Aug 18, 2009 6:25 am
by jackpf
Have you got errors turned on then?
What does
display?
Re: connectivty error
Posted: Tue Aug 18, 2009 6:28 am
by yasir_memon
there is no any error message just else condition is runing "error" is printed.
Re: connectivty error
Posted: Tue Aug 18, 2009 6:37 am
by jackpf
What does the code I posted display?
Re: connectivty error
Posted: Tue Aug 18, 2009 6:40 am
by yasir_memon
it shows this message
resource(2) of type (odbc link) resource(3) of type (odbc result)
Re: connectivty error
Posted: Tue Aug 18, 2009 6:43 am
by jackpf
Oh right, well you do have a connection then.
Wait, don't you mean odbc_num_rows() instead of odbc_fetch_row()?
Re: connectivty error
Posted: Tue Aug 18, 2009 6:48 am
by yasir_memon
now i am using this code but still else condition is runing.
<?php
$A=$_POST["text1"];
$B=$_POST["text2"];
$conn=odbc_connect('AKTMAPP','ERP_TEST','ERP_TEST');
$sql="SELECT * FROM USERS WHERE USR_NAME='$A' and PASSWORD='$B'";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{
exit("Error in SQL");
}
if(odbc_num_rows($rs)>0)
{
header("Location:
http://index.php");
}
else
{
echo "error";
}
odbc_close($conn);
?>
Re: connectivty error
Posted: Tue Aug 18, 2009 6:49 am
by jackpf
What does
display?
Your query must just be returning no rows...are you sure the username and password you're entering exists?
Re: connectivty error
Posted: Tue Aug 18, 2009 6:52 am
by yasir_memon
it displays
int(-1)
yes user name and password is there
Re: connectivty error
Posted: Tue Aug 18, 2009 6:59 am
by jackpf
Hmm, well the php manual says that odbc_num_rows returns -1 on an error.
Hmm....
What does
show?
Sorry for all the var_dump()s....but since I can't run the code myself, I can't see what it's returning

Re: connectivty error
Posted: Tue Aug 18, 2009 7:01 am
by yasir_memon
its ok dear now it displys
Fatal error: Call to undefined function odbc_fetch_rows() in C:\wamp\www\RMS\login.php on line 109
Re: connectivty error
Posted: Tue Aug 18, 2009 7:42 am
by jackpf
My bad, I meant odbc_fetch_row()
Sorry.
I'm used to mysql...