SV: [PHP-WIN] MySQL ADODB Error
| From: | Carsten Gehling | Date: | Thu, 18 Nov 2004 04:52:16 +0000 |
| Subject: | SV: [PHP-WIN] MySQL ADODB Error | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-24991@lists.php.net to get a copy of this message | ||
> -----Oprindelig meddelelse-----
> Fra: news [mailto:news@sea.gmane.org]På vegne af MikeA
> Sendt: 17. november 2004 19:15
> Til: php-windows@lists.php.net
> Emne: [PHP-WIN] 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@spam.org"))
>
> 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