Hi,
Forgive me if this is a stupid question, but google doesn't seem to be much help for it. I am using DBI with MySQL and am looking for a way to test if a query returned an empty recordset. For example, I issue the query:
$rs1 = $db1->prepare("SELECT * FROM users WHERE username = '" . $Usern
+ame_POST . "';");
Assume that I have the database connection set up correctly. I have tried a statement such as:
$rs1->execute;
if($rs1 != 'NULL')
{ report_error("username_exists"); }
else
{ report_error("username does not exist"); }
I have also tried placing the $rs1->execute; statement after the if statement, but that changed nothing. The if statement always evaluates to true. Will anyone take pitty on my with this question? I would really appreciate any advice. Thanks for reading my problem.
Joe
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.