Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
|
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 23rd, 2006, 03:57 AM
mr5 mr5 is offline
Registered User
 
Join Date: Apr 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with Ajax & PHP

Hello,

I am trying to write a check multi domain script by Ajax & PHP. User will input multi domains in seperate line by enter after each domain.

However, my PHP script backend can not split domains user inputed. You can test my AJAX at: http://www.liemonline.com/ajax

My getdata.php code:

<?
print_r(explode("\r\n", $_GET['domain']));
?>

Hope someone can help me. Thank you.

Regards,



 
Old June 23rd, 2006, 09:12 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

New lines aren't always the sequence "\r\n", it's possible that it's just an "\n" depending on the operating system.

The best thing to do is to strip out the "\r" character, so that you have consistency. You might also call encodeURIComponent() in the JavaScript, so that you are sending a proper URL-encoded string.

xhr.open("GET", "getdata.php?domain=" + encodeURIComponent(domain));

HTH!

Regards,
Rich

--
Author,
Beginning CSS: Cascading Style Sheets For Web Design
CSS Instant Results

http://www.catb.org/~esr/faqs/smart-questions.html
 
Old June 24th, 2006, 03:25 AM
mr5 mr5 is offline
Registered User
 
Join Date: Apr 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello,

Thank you very much. However, I decided to split the data by Javascript before send to PHP with: split() function. (Javascript works well with \r\n)

Thank you.

 
Old June 24th, 2006, 07:24 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Like I said, "\r\n" isn't always the sequence, carriage return followed by a new line is the Windows sequence for a newline. However, this isn't the case on Linux or Mac, and can even differ from browser to browser.

Regards,
Rich

--
Author,
Beginning CSS: Cascading Style Sheets For Web Design
CSS Instant Results

http://www.catb.org/~esr/faqs/smart-questions.html
 
Old August 17th, 2006, 09:16 AM
Registered User
 
Join Date: Feb 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to g.tamilselvan
Default

hai,

you'd better use some special characters to split instead of \r\n. u may use sequence of ##, ~~ and so on.
 
Old September 23rd, 2006, 11:45 PM
Registered User
 
Join Date: Sep 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to dharprog
Default

Hi,

I'm Newbie to Ajax getting problem to execute. What i'm asking is have i to add any libraries to work out ajax? I just bought a Book of wrox Publications of Professional AJax. I read basics even though its not working i'm getting error that "error on page" on status bar of IE. what i have to do to make it execute? I'm Using Php and Mysql as Back end and using versions 5.1.6 and 5.0.24 respectivley. Any Body answer me please...

Thank You...

 
Old December 14th, 2006, 07:35 AM
Authorized User
 
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

dharprog;

try visit this sites http://ssuren.spaces.msn.com

i hope this can help;))






Similar Threads
Thread Thread Starter Forum Replies Last Post
Session management with Ajax and PHP dnmk15 Ajax 7 June 21st, 2007 08:05 AM
mysql & php connection problem. Manu Sharma PHP Databases 2 March 2nd, 2007 07:03 AM
begin php & mysql - chapter 12, user_form.php jon_stubber Beginning PHP 1 March 9th, 2006 10:57 AM
Linux & KDE & C++ & QT & MYSQL & Kdevelop Munnnki Linux 0 January 2nd, 2005 05:41 PM
Error: movie.php & commit.php on p182-186, ch6 willburke BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 October 12th, 2004 02:48 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.