Home  |  Linux  | Mysql  | PHP  | XML
From:Jim Lucas Date:Thu Jul  2 01:36:11 2009
Subject:Re: exasperated again
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?
>

I was preaching this to you months ago. You should have error reporting turned on in a development
area.

by that I mean php should be set to display_errors = on and error_reporting = E_ALL

Give this a try in a development area and "you will see the errors of your ways..."

--
Jim Lucas

"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare
Navigate in group php.general at sever news.php.net
Previous Next


Your recent visits
Re: [PHP] Warning?
Re: [PHP] Re: Hi list --- justa simple question
[PHP] Re: Warning?
Re: [PHP] Re: PHP in HTML code
Re: PHP backup in Minnesota



  
© No Copyright
You are free to use Anything, but please consult your advocate before doing so as this website
also list content from other sources which may be copyrighted.
Site Maintained by Zareef Ahmed
Powered By PHP Consultants