php-general Digest 10 Apr 2009 05:28:25 -0000 Issue 6059

Topics (messages 291303 through 291322):

Re: difficult select problem
        291303 by: PJ
        291308 by: PJ
        291310 by: Andrew Ballard
        291314 by: PJ

Re: PHP and Send Mail
        291304 by: Michael A. Peters

Re: Escape Data In/Out of db [solved]
        291305 by: tedd
        291321 by: Jim Lucas

Hello, I have a question about php array max number
        291306 by: PeterDu
        291312 by: PeterDu
        291313 by: Bastien Koert
        291317 by: Jonesy

Re: codeigniter 'secure, non-secure content' pop up message in IE7
        291307 by: 9el

Re: opening utf-8 files - chinese mb characters
        291309 by: Shawn McKenzie
        291311 by: Andrew Ballard

unknown number of inputs
        291315 by: PJ
        291316 by: Shawn McKenzie
        291320 by: Jim Lucas

Please Help Me ASAP
        291318 by: kunal sharma
        291319 by: Jason Pruim

A Tool For Building PHP Web Apps
        291322 by: Paul M Foster

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
Jim Lucas wrote:
> PJ wrote:
>> Hi Jim,
>> Sorry I could not gat back to you on your suggestion. I've been under
>> the weather for a couple of days but am almost over it.
>> Your suggestion does not work... yet.
>> I'll insert comments & questions below...
>>
>> Jim Lucas wrote:
>>> PJ wrote:
>>>> I've searched the web, the tutorials, etc. with no luck and have asked
>>>> on MySql list with no luck and have even posted here with no replies.
>>>> So, let's try again:
>>>>
>>>> I am trying to limit the search for books to only those that start
>>>> with
>>>> "A" (does not have to be case sensitive); but within that selection
>>>> there may be a second author whose name may start with any letter
>>>> of the
>>>> alphabet.
>>>>
>>>> So, the real problem is to find if there is a second author in the
>>>> selection of books and to display that name.
>>>> My query shows all the books that begin with A:
>>>>
>>>> $SQL = "SELECT b.*, c.publisher, a.first_name, a.last_name
>>>>         FROM book AS b
>>>>         LEFT JOIN book_publisher as bp ON b.id = bp.bookID
>>>>         LEFT JOIN publishers AS c ON bp.publishers_id = c.id
>>>>         LEFT JOIN book_author AS ba ON b.id = ba.bookID
>>>>         LEFT JOIN author AS a ON ba.authID = a.id         WHERE
>>>> LEFT(last_name, 1 ) = '$Auth' ";
>>>>
>>>> Within the results there are some books that have 2 authors and now I
>>>> have to find if
>>>> there is a second author in the results and then be able to echo the
>>>> second author.
>>>> So far, I have not been able to figure out how to go about that.
>>>> Do I need to do another query to find the second author or can it
>>>> somehow be incorporated into the original query? Or can it be done
>>>> with a UNION ?
>>>> Please help.
>>>>
>>>>  
>>>>
>>> ... and we begin ...
>>>
>>> $SQL = "SELECT b.*, c.id AS publisher_id, c.publisher, a.id AS
>>> author_id, a.first_name, a.last_name
>>>         FROM book AS b
>>>         INNER JOIN book_publisher as bp ON b.id = bp.bookID
>>>         INNER JOIN publishers AS c ON bp.publishers_id = c.id
>>>         INNER JOIN book_author AS ba ON b.id = ba.bookID
>>>         INNER JOIN author AS a ON ba.authID = a.id
>>>         WHERE b.id IN (
>>>                 SELECT  b.id
>>>                 FROM    book AS b
>>>         INNER JOIN book_author AS ba ON b.id = ba.bookID
>>>                 INNER JOIN author AS a ON ba.authID = a.id
>>>                 WHERE   a.last_name LIKE '{$Auth}%'
>>>         )";
>> A written, the code does not produce a result.
>> Questions:
>> 1. why c.id AS publisher_id and a.id AS author_id? I do not see a
>> reference to these in the code
>> 2. why "a.last_name LIKE '{$Auth}%'? What does that change from
>> LEFT(last_name, 1) = '$Auth'? the LEFT clause will give me all authors
>> whose names begin with A; I don't care what the rest of the string may
>> be - the authors' last names always starts with a capital letter.
>> 3. What were you expecting to get as a result from the code? It looks to
>> me like the results will only give all authors whose names begin with A.
>> And that I am already getting with the code as I have written. Sorry for
>> my ignorance, but that is why I am asking for help.
>> 4. So far, no one has used the book_author.ordinal to select the author
>> ;  perhaps I have not been clear on that as that is what I use to
>> determine if there are more than 1 author. Ordinal 1 is for all authors
>> who are unique for a book; ordinal 2 is for authors who are the second
>> author for a book.
>>
>
> Thanks for explaining the ordinal significance.  Does it really make a
> difference if the ordinal is 1 or 2?  Does 1 indicate the primary
> author and the 2 indicate supporting authors???
I decided on the outset that there would only be a max or 2 authors in
the author fields as there are few books authored by more than 2
writers. So I assign ordinal 1 for the primary author and 2 for the
second(ary). I thought that would be necessary for differentiating
between the two.
If there are 3 authors, then that is entered under sub_title. And often
these "authors" are not authors but editors for the books then are
really anthologies.
I had not thought of searching for these under Authors. I suppose that
could be done by another type of search.
>
>
> If a book has three authors and all three had an ordinal of 2, would
> it make any difference then if one was 1 and the remaining two were
> marked 2?
>
> If it makes no difference, the the column is pointless.
>
> If it does make a difference (identifying one as 1 and the remaining
> as 2), then keep it and we will deal with that later.
>
> But, all this can be done without that column.
>
> Read my other email that I about to send, responding to a different
> part of this thread.
Will do.
>
>> Now, if my code is not too messy or cumbersome (I refer to your e-mail
>> of March 15) then what I really need is a way to save the book.id from
>> my query to a $tring and then use that to select the book in another
>> query that will give me the second author. I am wondering how that is
>> done; I have already used this in retrieving arrays but the id is
>> changed in a simple $bk_id = $result - damn, I forget where I found that
>> in the manuals. I used it in another situation like this:
>> $catvar = array_values($category[$categoryID]);
>> $cat = $catvar[1];
>>
>> $catvar was ids like 9, 6, 17, etc. and assigning it to $cat ranged them
>> as 1, 2, 3, 4, etc. (which is what I want to avoid)
>>
>> Then I should be able to do a
>> "SELECT CONCAT_WS(" ", first_name, last_name) as Author2
>> FROM author a, book b, book_author ba
>> WHERE $bk_id = ba.bookID && ba.authID = a.id"
>>
>> or
>>
>> "SELECT CONCAT(first_name, " ", last_name, book_author.ordinal) as
>> Author2
>> FROM author a, book b, book_author ba
>> WHERE $bk_id = ba.bookID && ba.authID = a.id"
>>
>> I probably have something wrong in the code; I haven't tried it as I am
>> not sure how to retrieve the $bk_id.
>> And the CONCAT with the ordinal, I can filter the 1 or the 2 when
>> echoing.
>>
>> I must be really long-winded but this is a long and complicated exercise
>> for my little brain. :'( 
>>> Ok, with those changes made, you will now see that your result set is
>>> going to have duplicate entries for each book. Well, almost
>>> duplicate...
>>>
>>> Basically what you need to realize is that you are talking about row
>>> counts compounding upon themselves...
>>>
>>> I will try and explain...
>>>
>>> if you had ten books with a total of 16 unique authors and 8 unique
>>> publishers, you would end up with a result set (without any WHERE
>>> clause) that was 10 x 16 x 8 = 1280 rows.
>>>
>>> now, say that you put a limit of "authors last name must start with
>>> and 'A'" on the select (like you have)
>>>
>>> say that three of the authors match that and of those three, they had
>>> 4 books that they have written and those 4 books were published by 2
>>> unique publishers.  You would end up with 3 x 4 x 2 = 24 rows in
>>> result set.
>>>
>>> I would consider handling all the above as I have stated, but you will
>>> need to add some sorting of the data in PHP to make sense of it all.
>>>
>>> something like the following should do. (completely untested!!!) typed
>>> right in the client here...
>>>
>>> $book_information = array();
>>>
>>> if ( ( $results = mysql_query($SQL, $db) ) !== false ) {
>>>     while ( $row = mysql_fetch_assoc($results) ) {
>>>         $book_information[$row['id']]['title'] = $row['title'];
>>>
>>>
>>>                 # NOTICE: this row is here so you can replace it with
>>> other information from the book table
>>>         $book_information[$row['id']]['...'] = $row['...'];
>>>
>>>
>>>         $book_information[$row['id']]['authors'][$row['author_id']] =
>>> array('first_name' => $row['first_name'],
>>>                                                                             
>>>       
>>> 'last_name' => $row['last_name']);
>>>       
>>> $book_information[$row['id']]['publishers'][$row['publisher_id']] =
>>> $row['publisher'];
>>>
>>>     }
>>> }
>>>
>>> Do a print_r($book_information) and you should get an understanding of
>>> what is happening.
>>>
>>> Jim Lucas
>>>
>>
>>
>
>


-- 
unheralded genius: "A clean desk is the sign of a dull mind. "
-------------------------------------------------------------
Phil Jourdan --- [email protected]
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


--- End Message ---
--- Begin Message ---
OK, so I owe you a big one  :-*

Your code works... now, I'm faced with a horrendous problem and that is
to make sense of it all :-)   

What I seem to get from this exercise is that I don't need the ordinals
at all.
Uuuuh... that's interesting. I get it. So now, I can update my
bookInsert script to eliminate the ordinals and just use the bookID and
authID .... which means I can list as may authors as I like and not
worry about limiting the number.
Looks like I will have to rewrite a bit of code. And I think this may
simplify my other code for publisher and categories.
Thank you, (kow-tow)- thank you, (kow-tow)- thank you, (kow-tow).

Now the silly questions = often I am curious what effect the differences
in code will have on performance.
For instance, why are you using author.last_name LIKE '{$Auth}%' rather
than LEFT('$Auth') ? As I have mentioned, it is not important what
follows the A

I think I understand the AS book_id and AS auth_id - is it to avoid
confusion with the book.id and author.id?

Anyway, I am beginning to see more light - could it be called
enLIGHTenment? :-D


Jim Lucas wrote:
> PJ wrote:
>> Gentlemen,
>>
>> First, let me thank you all for responding and offering suggestions. I
>> appreciate it and I am learning things.
>
> How about telling us/me what it did or did not do for you?
>
>> However, it looks like my message is not getting across:
>> The problem is not to retrieve only the authors whose last names begin
>> with A:
>>
>> 1) which books have a second author?
>> 2) who is the second author ?
>> This is determined by table book_author column ordinal (which can be 1
>> or 2) - if there is only 1 author for a book then there is no ordinal 2
>> linked to book_author bookID and authID.
>
> This is the first that I have heard about this 'ordinal'.  From your
> description above, I don't get what it does for you.  The book_author
> table should, basically, connect the books table to the authors table
> by a simple two column combination of ids.  So, I don't understand the
> significance of that field.  Could you explain it further please?
>
>>
>> The structure of the db:
>>
>> book
>>    id
>>    title
>>    sub_title
>>    descr
>>    comment
>>    bk_cover
>>    copyright
>>    ISBN
>>    language
>>    sellers
>>
>> author
>>    id
>>    first_name
>>    last_name
>>   book_author
>>    authID
>>    bookID
>>    ordinal
>>
>
> Thanks for the structure.  From this I can show you exactly what I
> would do to create the code. Minus the publishers information of
> course since you didn't supply the layout for those tables.
>
> $SQL = "
>     SELECT        book.*
>     FROM        book
>     INNER JOIN    book_author    ON (book.id = book_author.bookID)
>     INNER JOIN    author        ON (book_author.authID = author.id)
>     WHERE        author.last_name LIKE '{$Auth}%'
>     ";
>
> $books = array();
> $bookIDs = array();
> if ( ( $results = mysql_query($SQL, $db) ) !== false ) {
>     while ( $row = mysql_fetch_assoc($results) ) {
>         $books[$row['id']] = $row;
>         $bookIDs[] = $row['id'];
>     }
> }
>
> if ( count($bookIDs) > 0 ) {
>
>     print_r($bookIDs);
>     # above should result in a structure that shows an indexed array
> of book ids for their values.
>
>     $SQL = "
>     SELECT book.id AS book_id, author.id AS author_id,
> author.first_name, author.last_name
>         FROM        book
>         INNER JOIN    book_author    ON (book.id = book_author.bookID)
>         INNER JOIN    author        ON (book_author.authID = author.id)
>         WHERE        book.id IN ( " . join(',', $bookIDs) . " )
>     ";
>
>     $authors = array();
>     if ( ( $results = mysql_query($SQL, $db) ) !== false ) {
>         while ( $row = mysql_fetch_assoc($results) ) {
>             $authors[$row['book_id']][$row['author_id']] = $row;
>         }
>     }
>
>     print_r($authors);
>     # above should result in a multidimensional array of
> books/authors/(author data)
>     # Now, you should be able to have two nexted foreach loops.
>     # I will briefly give you an example.
>     foreach ( $books AS $bookID => $bookData ) {
>
>         # Display book information
>         echo '<h1>', $bookID, '</h1>';
>     print_r($bookData);
>
>         # Test to see if the book has any authors
>         if ( isset($authors[$bookID]) ) {
>
>             # Tell us how many authors we found
>             echo '<ul>Found: ', count($author[$bookID]), ' authors';
>
($authors[$bookID]) in line above :-)
>             # Loop through the authors
>             foreach ( $authors[$bookID] AS $authorID => $authorData ) {
>                 # Display the
>                 echo "<li>{$authorData['last_name']},
> {$authorData['first_name']}</li>\n";
>             }
>             echo '</ul>';
>         } else {
>             echo 'No authors found';
>         }
>         echo '<hr />';
>     }
> } else {
>     echo 'No books match your search pattern...';
> }
>
> ?>
>
> Ok, this is the second time I have written a script for you...  You
> owe me :)
>
> This should return to you a header that includes the book ID and then
> print all the data for the book.  That will be followed by any and all
> authors for the book.
>
> If it doesn't work...  well I don't know what to do then.
>
> But, try it!!!  Report back to the list what it did for you or what it
> missed on.
>
> Your responses have been very vague as to what an example did or
> didn't do for you.
>
> Tell us everything that worked or didn't and we might be able to help
> you to tweak the code so it DOES do what your are looking to do.
>
> Hope it works!
>
> Jim
>> categories and publishers are not realy relevant here...
>>
>> The code I have:
>>
>> $SQL = "SELECT b.*, c.publisher, a.first_name, a.last_name
>>         FROM book AS b
>>         LEFT JOIN book_publisher as bp ON b.id = bp.bookID
>>         LEFT JOIN publishers AS c ON bp.publishers_id = c.id
>>         LEFT JOIN book_author AS ba ON b.id = ba.bookID
>>         LEFT JOIN author AS a ON ba.authID = a.id
>>         WHERE LEFT(last_name, 1 ) = '$Auth' ";
>>
>> (PLEASE LET ME KNOW IF THERE IS SOMETHING WRONG WITH THE CODE)
>> It gives me these results:
>>
>> *array*
>> 6 =>
>> *array*
>> 'id' => string '6' /(length=1)/
>> 'title' => string 'Nubia.' /(length=6)/
>> 'sub_title' => string 'Corridor to Africa' /(length=18)/
>> 'descr' => string '' /(length=0)/
>> 'comment' => string '' /(length=0)/
>> 'bk_cover' => string '' /(length=0)/
>> 'copyright' => string '1977' /(length=4)/
>> 'ISBN' => string '0691093709' /(length=10)/
>> 'language' => string 'en' /(length=2)/
>> 'sellers' => string '' /(length=0)/
>> 'publisher' => string 'Princeton University Press' /(length=26)/
>> 'first_name' => string 'William Yewdale' /(length=15)/
>> 'last_name' => string 'Adams' /(length=5)/
>>
>> This is the first of 17 books and it would be sufficient if I were not
>> so damned demanding.
>> I know that there are several books in the list that have 2 authors. At
>> least 1 whose last name begins with A is an ordinal=2 (which is not
>> important when it comes to displaying) and there are a couple where
>> there are 2nd authors whose names begin with other letters of the
>> alphabet. It is these that I am targeting.
>> My question is:
>>
>> How do I filter my query to weed out these renegades?
>>
>> Can it be done using a concat as Author1 and another concat as Author2
>> (in place of the first_name and last_name joins ?
>> Or do I do another query just for the outlaws?
>>
>>
>
>


-- 
unheralded genius: "A clean desk is the sign of a dull mind. "
-------------------------------------------------------------
Phil Jourdan --- [email protected]
http://www.ptahhotep.com
http://www.chiccantine.com/andypantry.php

--- End Message ---
--- Begin Message ---
On Thu, Apr 9, 2009 at 1:39 PM, PJ <[email protected]> wrote:
[snip]
> Now the silly questions = often I am curious what effect the differences
> in code will have on performance.
> For instance, why are you using author.last_name LIKE '{$Auth}%' rather
> than LEFT('$Auth') ? As I have mentioned, it is not important what
> follows the A

The query optimizer can use an index on author.last_name to evaluate
"WHERE author.last_name LIKE '{$Auth}%' ". It simply seeks/scans the
index since the last_name values are ordered, and starts returning
values when it reaches the first row that begins with $Auth and stops
returning rows when it finds a value is greater than the pattern.

To evaluate "WHERE LEFT('$Auth', LENGTH('$Auth')) = '$Auth' ", the
server has to calculate a substring of last_name for every row in the
table and then compare those substrings to the value $Auth.

Andrew

--- End Message ---
--- Begin Message ---
Andrew Ballard wrote:
> On Thu, Apr 9, 2009 at 1:39 PM, PJ <[email protected]> wrote:
> [snip]
>   
>> Now the silly questions = often I am curious what effect the differences
>> in code will have on performance.
>> For instance, why are you using author.last_name LIKE '{$Auth}%' rather
>> than LEFT('$Auth') ? As I have mentioned, it is not important what
>> follows the A
>>     
>
> The query optimizer can use an index on author.last_name to evaluate
> "WHERE author.last_name LIKE '{$Auth}%' ". It simply seeks/scans the
> index since the last_name values are ordered, and starts returning
> values when it reaches the first row that begins with $Auth and stops
> returning rows when it finds a value is greater than the pattern.
>
> To evaluate "WHERE LEFT('$Auth', LENGTH('$Auth')) = '$Auth' ", the
> server has to calculate a substring of last_name for every row in the
> table and then compare those substrings to the value $Auth.
>
> Andrew
>
>   
Thanks Andrew. Just what I wanted to know. ;-)

-- 
unheralded genius: "A clean desk is the sign of a dull mind. "
-------------------------------------------------------------
Phil Jourdan --- [email protected]
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


--- End Message ---
--- Begin Message ---
Bob McConnell wrote:
*snip*

Just be aware that it does have a few bugs you may need to work around
or patch. The SourceForge tracker is at
<http://sourceforge.net/tracker/?group_id=26031&atid=385707>. I
submitted two reports last year against 1.73 which the tracker says were
summarily closed with no comment and apparently no action. The first one
is listed as fixed in the change logs for 2.0.3 and 2.3, but that was
not recorded in the tracker.

1. Incorrect line ending character. RFC 2821 and 2822 require CR/LF line
endings. PHPMailer only puts in the LF. Just because most current
clients can handle the single character is no excuse for doing it wrong.

2. Invalid use of Return-path for Sender. When you request a Sender
header, the email is written with Return-path instead. According to
those RFCs, the latter is reserved for use by transport agents and may
be rewritten or replaced anywhere in the chain. It should insert a
Sender line instead.

Bob McConnell


I wonder if that could be fixed by extending the class.
I'll have to look at it, I like standards compliance, the web would be a better place if standards were always strictly enforced.


--- End Message ---
--- Begin Message ---
At 5:03 PM +0200 4/9/09, Jan G.B. wrote:

You might want to use htmlspecialchars($str, ENT_QUOTES)

OUT from db to html

and

mysql_real_escape_string(stripslashes($_POST['yourself']));


IN to db from html

Thanks, that worked.

Cheers,

tedd


--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
tedd wrote:
At 5:03 PM +0200 4/9/09, Jan G.B. wrote:

You might want to use htmlspecialchars($str, ENT_QUOTES)

OUT from db to html

and

mysql_real_escape_string(stripslashes($_POST['yourself']));


The above tells me that you probably need to look at your magic quotes setting.

Typically, you will want to disable magic quotes in your php.ini file / VirtualHost Block / or somewhere else. This setting tells PHP to automagically escape your GET/POST data when PHP receives it from the web server (Apache/IIS/etc...). I recommend turning it off, but making darn sure you sanitize all input to script from and outside source.


IN to db from html

Thanks, that worked.

Cheers,

tedd




--
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

--- End Message ---
--- Begin Message ---
Hello,

I have an array including 2000 records in database,

but when fetch all of them, why just get 1500 records?

Does that depend on my computer?

Peter

__________ Information from ESET NOD32 Antivirus, version of virus signature 
database 3997 (20090409) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com




--- End Message ---
--- Begin Message ---
Hello,

I have an array including 2000 records in database,

but when fetch all of them, why just get 1500 records?

Does that depend on my computer?

Peter

__________ Information from ESET NOD32 Antivirus, version of virus signature 
database 3997 (20090409) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com




--- End Message ---
--- Begin Message ---
On Thu, Apr 9, 2009 at 2:36 PM, PeterDu <[email protected]> wrote:

> Hello,
>
> I have an array including 2000 records in database,
>
> but when fetch all of them, why just get 1500 records?
>
> Does that depend on my computer?
>
> Peter
>
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 3997 (20090409) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Could be the memory limit on the server, could be the query only returning
1500 rows.

-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
On Thu, 9 Apr 2009 10:08:12 -0700, PeterDu wrote:
> Hello,
>
> I have an array including 2000 records in database,
>
> but when fetch all of them, why just get 1500 records? 
>
> Does that depend on my computer?

Well, at least you hi-jacked a thread that did not pertain to PHP and 
put it back On Topic!



--- End Message ---
--- Begin Message ---
On Thu, Apr 9, 2009 at 6:56 PM, Jan G.B. <[email protected]> wrote:

> 2009/4/9 Yannick Mortier <[email protected]>:
> > 2009/4/9 9el <[email protected]>:
> >> ---------- Forwarded message ----------
> >> From: Sabrina Akter <[email protected]>
> >> Date: Thu, Apr 9, 2009 at 1:12 AM
> >> Subject: codeigniter 'secure, non-secure content' pop up message in IE7
> >> To: [email protected]
> >>
> >>
> >> Hello Experts,
> >>
> >> I badly need your help. My developed site's some pages are HTTPS, and
> >> other parts are HTTP. When I try to access the HTTPS page in IE it
> >> comes up with "secure & non-secure content " warning. I search on
> >> google to find out the solution. but almost every site suggest to
> >> change the IE setting. But, its not wish way to tell every visitor's
> >> to change  the IE setting. So, I want to stop this message with some
> >> coding. while searching, I found some advice to make all image to
> >> HTTPS, for https pages, I followed that, but still i am getting this
> >> same pop up warning. Is there any other way to solve my problem? Any
> >> one can help me on it? Please do reply.
> >>
> >> With Regards
> >> --------------------
> >> Sabrina Akter
> >> Web App. Developer
> >> 'IBACS' - www.ibacs.co.uk
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >
> > Look at the generated source code and try to find any files that are
> > included by absolute URL (search for http://) those have to be
> > eliminated. Make sure everything uses relative paths or comes over
> > SSL.
> >
>
> Yes. or absolute paths without protocoll and host. ;)
> works:
> src="/foo.bar"
> src="./foo.bar"
> src="https://otherserver/foo.bar";
>
>
> And also be on the lookout for blank src= attributes like in a iframe
> <iframe src="" id="foo">
> A bug in IE will show the mentioned popup when you have such code.
> Solution: src="javascript:void(0)"
>
> Bye


Great !  making all img, CSS, js to https solved it :)

--- End Message ---
--- Begin Message ---
Per Jessen wrote:
> Andrew Ballard wrote:
> 
>> A bit off topic, but Ctrl+I no longer brings up the Page Info in
>> Firefox like it used to -- at least on my Windows computers. (It opens
>> the bookmark list in the sidebar.) Does it do differently under Linux?
> 
> On FF 2.0.0.6 Ctrl-I brings up the info page - perhaps 3.0 changed that?
> 
> 
> /Per
> 

Same on 3.0 Linux.  Brings up the info page.

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
On Thu, Apr 9, 2009 at 1:53 PM, Shawn McKenzie <[email protected]> wrote:
> Per Jessen wrote:
>> Andrew Ballard wrote:
>>
>>> A bit off topic, but Ctrl+I no longer brings up the Page Info in
>>> Firefox like it used to -- at least on my Windows computers. (It opens
>>> the bookmark list in the sidebar.) Does it do differently under Linux?
>>
>> On FF 2.0.0.6 Ctrl-I brings up the info page - perhaps 3.0 changed that?
>>
>>
>> /Per
>>
>
> Same on 3.0 Linux.  Brings up the info page.
>
> --
> Thanks!
> -Shawn
> http://www.spidean.com
>

I'm, not positive, but as I recall this stopped working even under
version 2 on Windows. I just figured it was another annoyance of a
feature that was removed for some obscure reason, kind of like no
longer being able to see the Forms tab on the Page Info screen. (You
can get an extension to add this back in, but it seems nuts to me that
they took that out.)

Sorry to hijack the thread, but I see people suggest Ctrl+I a lot for
stuff like this and it just got me wondering if there other current
versions where it still worked.

Andrew

--- End Message ---
--- Begin Message ---
I have a script with $_POST and <form> to load data with text input.
Situation: enter name of author(s) for book. I have the script set up to
enter first_name, last_name for Author1 and the same for Author 2.
Check if entry 1 exists then proceed accordingly
Check if entry 2 exists then proceed accordingly.
Now, If I have three or more authors to enter, is there a way to add a
radio button to add more rows for input or to skip further inputs, if I
have to enter the inputs for each additional author?
I'm looking for a simple way to do this. Could or should Ajax be
involved in this somehow?

-- 
unheralded genius: "A clean desk is the sign of a dull mind. "
-------------------------------------------------------------
Phil Jourdan --- [email protected]
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


--- End Message ---
--- Begin Message ---
PJ wrote:
> I have a script with $_POST and <form> to load data with text input.
> Situation: enter name of author(s) for book. I have the script set up to
> enter first_name, last_name for Author1 and the same for Author 2.
> Check if entry 1 exists then proceed accordingly
> Check if entry 2 exists then proceed accordingly.
> Now, If I have three or more authors to enter, is there a way to add a
> radio button to add more rows for input or to skip further inputs, if I
> have to enter the inputs for each additional author?
> I'm looking for a simple way to do this. Could or should Ajax be
> involved in this somehow?
> 

Ajax would be a good way to go if it could be an undetermined number of
authors.  But if you have a limit (like 3 or 4 or 5) then just include
the text fields for that number.

For Ajax you might have a button or link that says "add more authors"
and when clicked the javascript adds an additional input to the form.

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
Shawn McKenzie wrote:
PJ wrote:
I have a script with $_POST and <form> to load data with text input.
Situation: enter name of author(s) for book. I have the script set up to
enter first_name, last_name for Author1 and the same for Author 2.
Check if entry 1 exists then proceed accordingly
Check if entry 2 exists then proceed accordingly.
Now, If I have three or more authors to enter, is there a way to add a
radio button to add more rows for input or to skip further inputs, if I
have to enter the inputs for each additional author?
I'm looking for a simple way to do this. Could or should Ajax be
involved in this somehow?


Ajax would be a good way to go if it could be an undetermined number of
authors.  But if you have a limit (like 3 or 4 or 5) then just include
the text fields for that number.

For Ajax you might have a button or link that says "add more authors"
and when clicked the javascript adds an additional input to the form.


This isn't a job for AJAX, it is a job for JavaScript.

REF:

AJAX - http://en.wikipedia.org/wiki/Ajax_(programming)

Dynamic Form Generation - 
http://www.faqts.com/knowledge_base/view.phtml/aid/1785/fid/129

I did a quick Google and came up with the two above examples. Others might have better suggestions. But I just wanted to point out the difference. AJAX, IMO, is bases on JavaScript talking to a server with the intent to send/receive data. DHTML/JavaScript/etc... are was to do what you are asking without ever needing to talk with the server. So it doesn't involve anything that AJAX was designed to solve.

I simply wanted to point out the different uses.  Hope I didn't step on 
anybodies toes.

--
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

--- End Message ---
--- Begin Message ---
 Hello,
I'm building my own website without any knowledge of PHP, & i'm almost done
with that..as my website works fine on my local server
i:e WAMPSERVER 2.0,
but the same code is not working on server...n i'm rilli ****'d of coz of
that...

The error is :"PHP Parse error: syntax error, unexpected $end in
/home/usang2me/public_html/sign_up.php on line 145"

"145" happens to be last line i:e "?>" , but here becoz of pattern..itz not
into its proper way...

&
After filling the sign up form correctly . it says ALL FIELD ARE
MANDATORY....i dont understand ...y so....i'm pasting my code here...please
help me asap ...
each and every suggestion will be appreciat'd



Here Is The Code:

<?php
$username = $_POST['username'];
$password1 = $_POST['password1'];
$password2 = $_POST['password2'];
$name = $_POST['name'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$code = $_POST['code'];
$phone = $_POST['phone'];
$email = $_POST['email'];
//$bankname = $_POST['bankname'];
//$bankbranch = $_POST['bankbranch'];
//$accountnumber = $_POST['bankac'];
$refer_id = $_POST['refer_id'];
//$country = $_POST['country'];
// Connects to your Database
include('database_connect_local.php');
//This makes sure they did not leave any fields blank
$minuser_len = 6; //username minimum length
$minpass_len = 6; //password minimum length
$mincode_len = 6; //code minimum length
$minphone_len = 10; //phone minimum length
//$refer_id_len = 6; //refer_id minimum length

if (strlen($username) < $minuser_len || strlen($password1) < $minpass_len ||
strlen($code) < $mincode_len || strlen($phone) < $minphone_len)
{
echo "<html>";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "<table align=center border=1 cellpadding=0 cellspacing=0
bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10>";
echo "<tr> <td align=center><p font color=black span
style=font-size:11pt;><b>Minimum length values for Username or Password or
Pincode or Mobile is missing. Please try again with correct
values.</b></span></font></p></td> </tr> </table> </html>";
include 'signup.php';
exit;
//die("User/password was not long enough!");
}elseif (!is_numeric($code) || !is_numeric($phone)){
echo "<html>";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "<table align=center border=1 cellpadding=0 cellspacing=0
bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10>";
echo "<tr> <td align=center><p font color=black span
style=font-size:11pt;><b>Non Numeric Character Where only Numeric Value is
Allowed.</b></span></font></p></td> </tr> </table> </html>";
include 'signup.php';
exit;
//}elseif (empty($username)|| empty($password1) || empty($password2) ||
empty($name) || empty($address) || empty($city) || empty($state) ||
empty($code) || //empty($phone) || empty($email) || empty($refer_id)){
//echo "<html>";
//echo "&nbsp;";
//echo "&nbsp;";
//echo "&nbsp;";
//echo "&nbsp;";
//echo "&nbsp;";
//echo "&nbsp;";
//echo "&nbsp;";
//echo "&nbsp;";
//echo "&nbsp;";
//echo "<table align=center border=1 cellpadding=0 cellspacing=0
bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10>";
//echo "<tr> <td align=center><p font color=black span
style=font-size:11pt;><b>All fields are Mandatory</b></span></font></p></td>
</tr> </table> //</html>";
//include 'signup.php';
}else{
// checks if the username is in use
$checkuser = mysql_query("SELECT username FROM id_users WHERE
username='$username'");
$username_exist = mysql_num_rows($checkuser);
$referid = mysql_query("SELECT username FROM id_users WHERE
username='$refer_id'");
$referid_exist = mysql_num_rows($referid);
if($username_exist != 0){
echo "<html>";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "<table align=center border=1 cellpadding=0 cellspacing=0
bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10>";
echo "<tr> <td align=center><p font color=black span
style=font-size:11pt;><b>I'm sorry but the username you specified has
already been taken. Please pick another one.</b></span></font></p></td>
</tr> </table> </html>";
unset($username);
include 'signup.php';
}elseif($referid_exist > 0){
echo "<html>";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "<table align=center border=1 cellpadding=0 cellspacing=0
bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10>";
echo "<tr> <td align=center><p font color=black span
style=font-size:11pt;><b>I'm sorry but the referral id doesn't exist. Please
check the referral id or enter the valid one.</b></span></font></p></td>
</tr> </table> </html>";
unset($username);
include 'signup.php';
}else{
// this makes sure both passwords entered match
if ($password1 != $password2) {
die('Your passwords did not match.');
}else{
//}
// now we insert it into the database
//$password3 = md5($_POST['password1']);//
$insert = "INSERT INTO id_users (username, password, name, address, city,
state, code, phone, email, payment_status, member_status, total_member,
refer_id)
VALUES ('$username', '$password1', '$name', '$address', '$city', '$state',
'$code', '$phone', '$email', '0', '0', '0', '$refer_id'); UPDATE id_users
SET refer_id = '1' where username = 'refer_id';";
$queries =
preg_split("/;+(?=([^'|^\\\']*['|\\\'][^'|^\\\']*['|\\\'])*[^'|^\\\']*[^'|^\\\']$)/",
$insert);
foreach ($queries as $query){
if (strlen(trim($query)) != 0) mysql_query($query) or die(mysql_error());
}
//mysql_query($insert) or die(mysql_error());
//mysql_close();

//$update = "update id_users set refer_id='1' where username='refer_id'";
//mysql_query($update) or die(mysql_error());
//mysql_close();
echo "<html>";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "<table align=center border=1 cellpadding=0 cellspacing=0
bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10>";
echo "<tr> <td align=center><p font color=black span
style=font-size:11pt;><b>You have successfully Registered, Please
Login</b></span></font></p></td> </tr> </table> </html>";
include 'login.php';
}
}
}
?>

Thanks Kunal

--- End Message ---
--- Begin Message ---


Jason Pruim

On Apr 9, 2009, at 11:03 PM, kunal sharma <[email protected]> wrote:

Hello,
I'm building my own website without any knowledge of PHP, & i'm almost done
with that..as my website works fine on my local server
i:e WAMPSERVER 2.0,
but the same code is not working on server...n i'm rilli ****'d of coz of
that...

The error is :"PHP Parse error: syntax error, unexpected $end in
/home/usang2me/public_html/sign_up.php on line 145"

"145" happens to be last line i:e "?>" , but here becoz of pattern..itz not
into its proper way...

&
After filling the sign up form correctly . it says ALL FIELD ARE
MANDATORY....i dont understand ...y so....i'm pasting my code here...please
help me asap ...
each and every suggestion will be appreciat'd



Here Is The Code:

<?php
$username = $_POST['username'];
$password1 = $_POST['password1'];
$password2 = $_POST['password2'];
$name = $_POST['name'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$code = $_POST['code'];
$phone = $_POST['phone'];
$email = $_POST['email'];
//$bankname = $_POST['bankname'];
//$bankbranch = $_POST['bankbranch'];
//$accountnumber = $_POST['bankac'];
$refer_id = $_POST['refer_id'];
//$country = $_POST['country'];
// Connects to your Database
include('database_connect_local.php');
//This makes sure they did not leave any fields blank
$minuser_len = 6; //username minimum length
$minpass_len = 6; //password minimum length
$mincode_len = 6; //code minimum length
$minphone_len = 10; //phone minimum length
//$refer_id_len = 6; //refer_id minimum length

if (strlen($username) < $minuser_len || strlen($password1) < $minpass_len ||
strlen($code) < $mincode_len || strlen($phone) < $minphone_len)
{
echo "<html>";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "<table align=center border=1 cellpadding=0 cellspacing=0
bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10>";
echo "<tr> <td align=center><p font color=black span
style=font-size:11pt;><b>Minimum length values for Username or Password or
Pincode or Mobile is missing. Please try again with correct
values.</b></span></font></p></td> </tr> </table> </html>";
include 'signup.php';
exit;
//die("User/password was not long enough!");
}elseif (!is_numeric($code) || !is_numeric($phone)){
echo "<html>";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "<table align=center border=1 cellpadding=0 cellspacing=0
bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10>";
echo "<tr> <td align=center><p font color=black span
style=font-size:11pt;><b>Non Numeric Character Where only Numeric Value is
Allowed.</b></span></font></p></td> </tr> </table> </html>";
include 'signup.php';
exit;
//}elseif (empty($username)|| empty($password1) || empty($password2) ||
empty($name) || empty($address) || empty($city) || empty($state) ||
empty($code) || //empty($phone) || empty($email) || empty($refer_id)){
//echo "<html>";
//echo "&nbsp;";
//echo "&nbsp;";
//echo "&nbsp;";
//echo "&nbsp;";
//echo "&nbsp;";
//echo "&nbsp;";
//echo "&nbsp;";
//echo "&nbsp;";
//echo "&nbsp;";
//echo "<table align=center border=1 cellpadding=0 cellspacing=0
bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10>";
//echo "<tr> <td align=center><p font color=black span
style=font-size:11pt;><b>All fields are Mandatory</b></span></font></ p></td>
</tr> </table> //</html>";
//include 'signup.php';
}else{
// checks if the username is in use
$checkuser = mysql_query("SELECT username FROM id_users WHERE
username='$username'");
$username_exist = mysql_num_rows($checkuser);
$referid = mysql_query("SELECT username FROM id_users WHERE
username='$refer_id'");
$referid_exist = mysql_num_rows($referid);
if($username_exist != 0){
echo "<html>";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "<table align=center border=1 cellpadding=0 cellspacing=0
bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10>";
echo "<tr> <td align=center><p font color=black span
style=font-size:11pt;><b>I'm sorry but the username you specified has
already been taken. Please pick another one.</b></span></font></p></ td>
</tr> </table> </html>";
unset($username);
include 'signup.php';
}elseif($referid_exist > 0){
echo "<html>";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "<table align=center border=1 cellpadding=0 cellspacing=0
bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10>";
echo "<tr> <td align=center><p font color=black span
style=font-size:11pt;><b>I'm sorry but the referral id doesn't exist. Please check the referral id or enter the valid one.</b></span></font></p></ td>
</tr> </table> </html>";
unset($username);
include 'signup.php';
}else{
// this makes sure both passwords entered match
if ($password1 != $password2) {
die('Your passwords did not match.');
}else{
//}
// now we insert it into the database
//$password3 = md5($_POST['password1']);//
$insert = "INSERT INTO id_users (username, password, name, address, city, state, code, phone, email, payment_status, member_status, total_member,
refer_id)
VALUES ('$username', '$password1', '$name', '$address', '$city', '$state', '$code', '$phone', '$email', '0', '0', '0', '$refer_id'); UPDATE id_users
SET refer_id = '1' where username = 'refer_id';";
$queries =
preg_split("/;+(?=([^'|^\\\']*['|\\\'][^'|^\\\']*['|\\\'])*[^'|^\\ \']*[^'|^\\\']$)/",
$insert);
foreach ($queries as $query){
if (strlen(trim($query)) != 0) mysql_query($query) or die(mysql_error());
}
//mysql_query($insert) or die(mysql_error());
//mysql_close();

//$update = "update id_users set refer_id='1' where username='refer_id'";
//mysql_query($update) or die(mysql_error());
//mysql_close();
echo "<html>";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "&nbsp;";
echo "<table align=center border=1 cellpadding=0 cellspacing=0
bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10>";
echo "<tr> <td align=center><p font color=black span
style=font-size:11pt;><b>You have successfully Registered, Please
Login</b></span></font></p></td> </tr> </table> </html>";
include 'login.php';
}
}
}
?>

Thanks Kunal

Just based on a quick look i'd guess you don't have the right number of curly braces at the end of the file.
--- End Message ---
--- Begin Message ---
Here's a hairbrained idea I was kicking around. I object to the idea of
including 15 or 30 files in a PHP application just to display one page
on the internet. It makes the coding faster, but it makes the display
slower and seems silly to me.

So what if you had a tool or a set of tools where you could write code
snippets and such, and then hit a button or issue a command, and
everything you specified got written into a single file? You'd specify
that this page needs to read the config, set up a database connection,
validate these fields, etc. When you were done, it would write all this
code to a *single* file, which the user would invoke by surfing to that
page. The resulting code would be *static*, not like what results from
most templating systems. So rather than specify a specific variable
value in the resulting file, it would embed the PHP code to display the
variable, etc.

What might be the liabilities of something like that? Would there be
security issues? Would there be increased difficulty in debugging? What
can you think of?

Paul

-- 
Paul M. Foster

--- End Message ---

Reply via email to