SV: MySQL ADODB Error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Oprindelig meddelelse-----
> Fra: news [mailto:news@xxxxxxxxxxxxx]På; vegne af MikeA
> Sendt: 17. november 2004 19:15
> Til: php-windows@xxxxxxxxxxxxx
> Emne:  MySQL ADODB Error
>
>
> I am getting the following error:
>
>  ErrorMsg for Database - Error:
>
> There is no error being returned!  I cannot figure out what the
> problem is.
> So I am hoping additional eyes will catch it for me.  I have debug set on
> (as you will see in code below) and this is what is returned:
>
>  (mysql): SELECT * FROM Alumni WHERE ((AlumID = 1) AND (Name_First =
> "Xxxxxxx") AND (Name_Last = "Yyyyyy") AND (EMail = "1234@xxxxxxxx"))
>
> It is correct.  I have the MySQL Query tool and have checked it out.
> Everything looks good!
>
> And here is the code:
>
>     $secure_query = 'SELECT * FROM Alumni WHERE ((AlumID = 1) AND
> (Name_First = "'.$_REQUEST['secfirst']
>                     .'") AND (Name_Last = "'.$_REQUEST['seclast'].'") AND
> (EMail = "'.$_REQUEST['secemail'].'"))';
>     $db = mysql_connect($dbhost, $dblogin, $dbpass);
>     $dbconn->SetFetchMode(ADODB_FETCH_ASSOC);
>     $dbconn->debug=true;
>      mysql_select_db($dbname, $db);
>     $result = &$dbconn->Execute($secure_query);
>     if (!$mysql_select_db) die ('ErrorMsg for Database - Error: ' .
> $dbconn->ErrorMsg());
>     if ($result->RecordCount() == 0)
>       {
>        die ('<font size="+2" color="red"><b>Error validating you. Cannot
> continue.</b></font>');
>       }
>     $t->set_file('index', 'admin/index2.ihtml');
>     $t->set_var("orgname", $orgname);
>     $t->set_var("title", $areadesc);

You are mixing ADODB code with the traditional way of using MySQL. I don't
think that is healthy. Try this instead:

$dbconn = &ADONewConnection('mysql');
$dbconn->PConnect($dbhost, $dblogin, $dbpass, $dbname);
$dbconn->SetFetchMode(ADODB_FETCH_ASSOC);
$dbconn->debug=true;

$result = &$dbconn->Execute($secure_query);
if ($result->RecordCount() == 0)
{
    die ('<font size="+2" color="red"><b>Error validating you. Cannot
continue.</b></font>');
}
$t->set_file('index', 'admin/index2.ihtml');
$t->set_var("orgname", $orgname);
$t->set_var("title", $areadesc);


Also note a minor detail about the debug attribute:

$dbconn->debug=true;

Don't confuse this with a boolean value. Correct values are: Empty-string =>
no debugging, non-empty string => Debugging

- Carsten

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.289 / Virus Database: 265.3.1 - Release Date: 15-11-2004

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux