Re: exasperated again

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

 



2009/7/4 PJ <af.gourmet@xxxxxxxxxxxx>:
> Ashley Sheridan wrote:
>> On Sat, 2009-07-04 at 10:47 -0400, PJ wrote:
>>
>>> Jim Lucas 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?
>>>>>
>>>>>
>>>> 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..."
>>>>
>>>>
>>> The error reporting is always on as you suggested and I use it all the time.
>>> But error reporting cannot report a non-existing error - a human stupid
>>> error that I finally caught - msql instead of mysql... oh. well... :-(
>>>
>>> --
>>> Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
>>> -------------------------------------------------------------
>>> Phil Jourdan --- pj@xxxxxxxxxxxxx
>>>    http://www.ptahhotep.com
>>>    http://www.chiccantine.com/andypantry.php
>>>
>>>
>>>
>> Actually, if you had error reporting on, it should have at least picked
>> that up as a function that was not defined. You do mention you get a lot
>> of white pages instead of errors, which suggests that either you do not
>> have errors turned on, or you are turning them on from within PHP,
> What do you mean "from within PHP" ?
> Isn't this enough in the script?
> error_reporting(E_ALL);
> ini_set('display_errors', 1);

As Ash points out that will not display errors in the code syntax
since they prevent any of your script from being executed. You're
better off setting these values in php.ini.

-Stuart

-- 
http://stut.net/

>>  which
>> can sometimes fail if there are fatal errors in the code.
>>
>> Thanks
>> Ash
>> www.ashleysheridan.co.uk
>>
>>
>>
>
>
> --
> Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
> -------------------------------------------------------------
> Phil Jourdan --- pj@xxxxxxxxxxxxx
>   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
>
>

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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux