Re: exasperated again - shot in the foot
| From: | Bastien Koert | Date: | Tue, 30 Jun 2009 20:50:34 +0000 |
| Subject: | Re: exasperated again - shot in the foot | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-294763@lists.php.net to get a copy of this message | ||
On Tue, Jun 30, 2009 at 4:48 PM, PJ<af.gourmet@videotron.ca> wrote:
> PJ wrote:
>> Could somebody please explain to me what is wrong with this code?
>> In my script it works, returns the correct id, but when I try it in a
>> test pages, nothing in the world gets it to work. This is rather
>> frustrating, again:
>> THIS WORKS IN ANOTHER PAGE; IN THE TEST PAGE ID DOES NOT.
>> $sql = "SELECT id FROM publishers
>> WHERE publisher = 'whoever'";
>> $result = mysql_query($sql,$db);
>> $row = mysql_fetch_assoc($result);
>> if (mysql_num_rows($result) !== 0) {
>> $pub = $row['id'];
>> Syntax is ok, echo "hello"; works.
>>
>>
>> This works in the test page:
>> $aid = array();
>> $ord = array();
>> $sql = "SELECT authID, ordinal
>> FROM book_author WHERE bookid = 624 ORDER BY ordinal ASC";
>> $result = mysql_query($sql, $db);
>> //$row = mysql_fetch_assoc($result);
>> while ( $row = mysql_fetch_assoc($result) ) {
>> $aid[]=$row['authID'];
>> $ord[]=$row['ordinal'];
>> }
>> var_dump($aid);
>> echo "<br />";
>> var_dump($ord);
>> echo $aid[0], " - ";
>> echo $ord[0];
>>
>> This does not:
>> $fi="joe"; $la="joe";
>> $sql = "SELECT id FROM author
>> WHERE first_name = '$fi' && last_name =
>> '$la'";
>> $result = msql_query($sql, $db);
>> $row = mysql_fetch_assoc($result);
>> $count=mysql_num_rows($result);
>> echo $count;
>> if (mysql_num_rows($result) > 0) {
>> $a_id=$row['id'];
>> }
>> echo $a_id, "<br /><br />";
>> The test page prints out echo "some text"; but no results when the
>> results are there....
>> Tell me I have missed something simple here, or is this normal for php ?
>> I have checked the queries on Mysql command line and they are fine.
>> I have verified the syntax and Netbeans tells me it is fine.
>> Same results Firefox3 (2 machines) & IE 8.
>> What is not fine?
>>
>>
> Damn, it's frustrating to find that there is a difference between msql
> and mysql... ouch, the foot hurts now!
>
> --
> Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
> -------------------------------------------------------------
> Phil Jourdan --- pj@ptahhotep.com
> http://www.ptahhotep.com
> http://www.chiccantine.com/andypantry.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Blame the native, libraries that is
--
Bastien
Cat, the other other white meat