Jump to content

Recommended Posts

$result=odbc_exec($strcon, $sql); //executing select * statement

//need help from here down

$count=odbc_fetch_array($result);

if($count==1)                                     //at least one row must exist

{

$rows=odbc_fetch_object($result);

 

Thanks in advance

 

Try this.  What does it display?  I would expect it is a row of data, and not the count that you expected.

$result=odbc_exec($strcon, $sql); //executing select * statement
//need help from here down
$count=odbc_fetch_array($result);
var_dump($count);

Try the following.  It should get one row at a time.

while($row=odbc_fetch_array($result)) {
    var_dump($row);
}

If you want to know how many rows you get, experiment with http://php.net/manual/en/function.odbc-num-rows.php.

 

odbc_fetch_array() and odbc_fetch_object() are basically the same but one returns an array and the other returns.. wait for it... an object.  There is no reason to do one, and then the other, but if you truly wanted both, I am sure their is a function for it.

 

PS.  I believe a PDO version for obdc exists, and you should definitely us it and use prepared statements.

$result=odbc_exec($strcon, $sql);

$count=odbc_fetch_array($result);

//var_dump($count);                         //This does dump the info on the record in the db

if($count==1)

while($row=odbc_fetch_array($result)) {

// var_dump($row);                           //This does not get the data and tells me not found int db

$pass  =  $rows['password'];          //FETCHING PASS

echo "your pass is ::".($pass)."" ;   //DISPLAYING PASSWORD

} else {

I'm still trying to get the password, username and email to populate at the bottom.

 

$sql="SELECT * FROM $tbl_name WHERE email='$email'";

$result=odbc_exec($strcon, $sql); //executing select * statement

//need help from here down

$count=odbc_fetch_array($result);

var_dump($count);                          //this does dump a row of data, but it looks like this.

//array(5) { ["id"]=> string(1) "1" ["username"]=> string(3) "dlb" ["email"]=> string(20) "dlb@someemail.com" ["password"]=> string(5) "somepassword" ["active"]=> string(1) "1" }

if($count==1)                                     //at least one row must exist

{

$rows=odbc_fetch_array($count);

  $pass  =  $rows['password'];//FETCHING PASS

  echo "your pass is ::".($pass)."" ;

  echo "<br/>";

  $username  =  $rows['username'];//FETCHING USERNAME

  echo "your username is ::".($username);

  echo "<br/>";

  $email  =  $rows['email'];//FETCHING USERNAME

  echo "your email is ::".($email);

} else {

Even though you can see the information that you want in the contents of that var_dump() after the first odbc_fetch_array($result) ?

 

I'll - type- slowly - for - you -

 

You - have - the - results - after - that - first - fetch. - After - that - there- are - no - more - records - left - to - fetch - so - the - results - of - the - next - fetch - are - empty.

You're calling odbc_fetch_array() twice, and each call is “destructive” in the sense that it removes the next row from the result set. When there's one row, only the first call gets it. The second call cannot fetch anything.

 

How about you remove the first “test call” altogether and do your var_dump() when the data is actually supposed to be fetched?

Even though you can see the information that you want in the contents of that var_dump() after the first odbc_fetch_array($result) ?

 

I'll - type- slowly - for - you -

 

You - have - the - results - after - that - first - fetch. - After - that - there- are - no - more - records - left - to - fetch - so - the - results - of - the - next - fetch - are - empty.

Maybe it's pain from your age or who knows what. But if you read the rules. I joined this forum to try and understand php. I'm stuck using and access.mdb and need a password recovery script. I have searched the web and only find basic login scripts that use odbc_connect. I'm guessing no one wants to create a full script. But none of them have a password recovery script. So my options were to find one that works with mysql and try to modify it. I was understanding phpfreaks forum was for helping people like me understand php scripts. But I don't need flamed by a "Moderator" just because I don't understand.

Thanks everyone for the help you have given and have a good weekend or whats left of it.

 

Forum DO NOT's
  1. Do not flame other users.

He “flamed” you? C'mon.

 

You've had a mental block, and somebody made fun of it. Yes, that can happen on the Internet. So what? Your project is fine, being new to PHP is fine, and there are plenty of people willing to help you. Fix the problem and move on.

 

When you don't understand something, it's generally a good idea to address it directly and ask specific questions. Ignoring replies or merely stating that you don't understand them isn't really helpful. It can also be frustrating after a while.

  • Like 1

OP - if you think Barand 'flamed' you you haven't seen anything yet.  Barand is one of the MOST helpful on here so if he took the time to do what he did he is TRYING to tell you something but you aren't getting it.  You were told twice to stop doing the extra (first) fetch and you didn't get it.  Hard to "not understand" something that direct so I don't blame Barand for his last response.  Neither should you.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.