[PHP] Re: Login and select Query in Mysql
It is usually wise to search through old posts before posting a question that's been answered before all over again. Here is a previous answer given by myself to someone who asked the same question as you: The easiest way is to use cookies. =CODE http://$SERVER/index2.php";); exit(); } else { header("Location:http://$SERVER/error.html";); } ?> This code takes in input from a form as simple as this: Login: Password: Checks it against the database values using the function 'authenticateUser', returns TRUE or FALSE. If true, sends the user onto the correct page, if false, sends them to some error page. Now, in each other file, you'll need to check the cookies. The values for the cookies are sent automatically by the user's browser. In this particular examples, the cookie variables are named '$cookie_user' and '$cookie_passwd'. You can see in the example how those are set. You will check the cookies using the exact same 'authenticateUser' function. Except in these files, you will use the cookie values as the parameters to the function instead of the form values. I.e. authenticateUser($cookie_user,$cookie_passwd); Hope this helps. Best regards, Jeremy Reed "Jack" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Dear all > I want to provide a login page to the user when they want to visit my > website, i got no idea what should i used. > First i have a login.php page which got two input box, one for username and > one for password. > Then i have a login table with mysql database which contain the valid user > and password. > And i have a index.htm which let the user browse my website.This index.htm > is consist of three frame, top, left and main. Each frame contain different > page(.php). > > Task : > User will login first through login.php, then the username and password > provided by user will need to match the table called login. > Once the username and password is correct, the username will be hold in a > place for the further use inside the website(eg: when user want to see the > leave history records, it will only show it's own record by select the query > using the username section). > then user will direct into index.htm. > > Could someone pls give me a idea how i should make this system work?? > > Thx > Jack > [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: File Upload Question...
Your first question. To see that the file uploaded successfully using the web browser, one would have to have access to your computer's file system. In her book, she used this merely as an example to show that the file had, indeed, been uploaded. This should not be used as something that you allow your web users to do to confirm the receipt of the file. Instead, send them an email, show them a directory listing, etc. Your second question, the name given to the image should be whatever the *value* of the variable used to copy() it. You should, however, come up with a naming scheme that allows you to ensure that you do not overwrite any uploaded files--especially if you expect a lot of traffic and/or users using this feature. Your third question, the mime-type pjpg is functionally the same as the mime-type jpeg. There's nothing you need to worry about there. "Anthony Ritter" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Merry Christmas everybody. > > I am using MS Windows 98 with Apache and following an example in Julie > Meloni's "PHP - Fast and Easy" (Chapter 10) in which she describes file > uploading using PHP on page 168-174. > > She has two files: > 1) an html form to receive the input from the user for the file to be > uploaded > 2) a .php script to accept the variable and use the copy() function. > . > > The scripts are as follows: > (html form) > > > > Upload a File > > > > Upload a File > > > > File to Upload: > > > > > > > > > > (.php script) > > if ($img1_name != "") { > > @copy("$img1", "c:/Program Files/Apache Group/Apache/htdocs/$img1_name") > or die("Couldn't copy the file."); > > } else { > > die("No input file specified"); > > } > > ?> > > > > Successful File Upload > > > > Success! > > You sent: , a > byte file with a mime type of . > > > > .. > > My questions: > I am able to upload a file from My Documents to the Apache server however > in her book, she describes that the user can verify that the file was > uploaded to the server by going to: > > File/ Open Page / in ones web browser to navigate through their filesystem > to > find the file that was uploaded. There is a screenshot in the book that > shows the .jpeg file on the screen with the browser at: > file:///C/Apache/htdocs/blahblah.jpg > > I can't seem to verify that the file exists using this method. > > The only way I can verify that the file was indeed uploaded is to go into > the folder within Apache that was specified in the path and check there. > > *How can I check by going through the browser window?* > > Next question: > > When I check that the file was uploaded, the file is saved in: > C:/Program Files/Apache Group/Apache/htdocs/$img1_name > > as the *regular *.jpeg name I originally gave it - not the variable - $img1. > > Is this correct? Or, should the file be saved as: > img1? > > And the last question: > This is the line I received upon sending the file: > > You sent: KewpieSmall.jpeg, a 3127 byte file with a mime type of > image/pjpeg. > > In her book, it says: > image/jpeg. > > What is: > image/pjpeg.? > > Many thanks and best wishes to all for a happy and healthy new year. > Tony Ritter > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] PHP/SQL login problems
I am having problems connecting and pulling data from a local SQL server. I have set up a user and, as far as I can tell, all the settings for the user are correct. However, when I try to pull data using the user, I get empty result sets--almost as if I don't have SELECT permissions. When I log in via Query Analyzer with the same login/pass, I am able to pull the data with no problems. Also, when I use the same code but log into an offsite database, the code works fine (except for the lag of pulling large amounts of data--which is what I'm trying to avoid) The only thing I can figure that might be affecting it is the ownership. The owner of the DB is 'dbo'--because this is a straight copy of a database on an offsite server. Any help would be greatly appreciated. Best regards, Jeremy Reed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] PHP question regarding Cold Fusion
Cold Fusion, as far as I'm concerned, stinks. However, I have been involved in porting a website from Cold Fusion to PHP and during this transmogrification, I've come across something I'm not sure how to emulate in PHP. Perhaps if there are any CF/PHP gurus out there, they can help me out. The tag I am talking about is . This tag allows you to emulate the posting of a form, but also allows you to capture the results of the post. There are a couple of forms written in CF that connect to the merchant account, check a credit card, for example, and then wait for the approval/denial response. Is there anything in PHP that can do this same kind of thing? Any help would be appreciated. Best regards, Jeremy Reed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] using sendtohost on a secure site
The function sendtohost: -BEGIN CODE function sendToHost($host,$method,$path,$data,$useragent=0) { // Supply a default method of GET if the one passed was empty if (empty($method)) $method = 'GET'; $method = strtoupper($method); $fp = fsockopen($host,443); echo("open"); if ($method == 'GET') $path .= '?' . $data; fputs($fp, "$method $path"); fputs($fp, "Host: $host\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\n"); fputs($fp, "Content-length: " . strlen($data) . "\n"); if ($useragent) fputs($fp, "User-Agent: MSIE\n"); fputs($fp, "Connection: close\n\n"); if ($method == 'POST') fputs($fp, $data); while (!feof($fp)) { $buf .= fgets($fp,128); echo("buf: " . $buf); } fclose($fp); echo("close"); echo($buf); return $buf; } -END CODE Is great for posting results to a regular http site. But what I need to do is post to a secure site (https). I looked through some of the php documentation and couldn't find anything about manually encrypting the data to send or anything like that. Any help would be greatly appreciated. Thanks, Jeremy Reed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] unable to load dynamic library etc. etc.
I keep getting this error message and cannot figure out why. The extension_dir is set correctly in the php.ini, I have put the .dlls into every conceivable directory I can think of and nothing seems to work. Anybody else had and fixed this problem? Thanks, Jeremy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] unable to process form data
I was able to fix the 'unable to find dynamic etc.' error thanks to you guys. Now I have a new problem. It seems that I am unable to process form data. Before upgrading to 4.1.1, you were able to refer to the form data simply by concatenating a '$' and the form element name i.e. would have been known as $silly in the php script the form was posted to. However, this doesn't seem to be working now. What's going on? Was there some directive I forgot to set in the php.ini file or something? Thanks, Jeremy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unable to load dynamic library etc. etc.
Thanks. Everything is fixed. A helpful tool I found useful is 'depends.exe'. It finds and lists problems with dependencies on .dll files. It was quite helpful in tracking down the problem. Jeremy "Ray Hunter" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Place all the dlls in the same directory as the php.exe file and in your > php.ini file have the extension_dir = .\ (windows). > > This works for me great... > > Ray Hunter > Firmware Engineer > > ENTERASYS NETWORKS > > > -Original Message- > From: Jeremy Reed [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 21, 2002 9:30 AM > To: [EMAIL PROTECTED] > Subject: [PHP] unable to load dynamic library etc. etc. > > > I keep getting this error message and cannot figure out why. The > extension_dir is set correctly in the php.ini, I have put the .dlls into > every conceivable directory I can think of and nothing seems to work. > > Anybody else had and fixed this problem? > > Thanks, > > Jeremy > > > > -- > 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
[PHP] Re: unable to process form data
That was it. Thanks a bunch. Jeremy "Cc Zona" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > In article <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] (Jeremy Reed) wrote: > > > I was able to fix the 'unable to find dynamic etc.' error thanks to you > > guys. Now I have a new problem. It seems that I am unable to process form > > data. Before upgrading to 4.1.1, you were able to refer to the form data > > simply by concatenating a '$' and the form element name i.e. > > As of 4.1, you need to use the new arrays $_GET, $_POST, $_COOKIE, etc. or > else turn register_globals back on. See > <http://www.php.net/release_4_1_0.php> for more info. > > -- > CC -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Authorize.net example
Ahh, you had the same problem as I. Fortunately, I've worked out a pretty good fix. It makes use of the CURL module in PHP. I think CURL comes standard in the 4.x versions of PHP, but I'm not sure. Anywho, here's the code: --BEGIN CODE- https://url.authnet.com";); $data = "x_Version=3.0&x_Login=loginname&x_adc_url=False&x_adc_delim_data=TRUE&x_car d_num=1234123412341234&x_exp_date=0104&x_Amount=24.45&x_Test_Request=TRUE&x_ Type=AUTH_CAPTURE&x_first_name=FNAME&x_last_name=LNAME&x_email_merchant=TRUE "; curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_POSTFIELDS, $data); $buf = curl_exec ($ch); //execute post and get results echo($buf); curl_close ($ch); ?> -END CODE- Be sure to include the 'https://' in the curl_init() function. That is what tells the program that all the data should be encoded. Obviously, the '$data' variable holds all the post data and you can, of course, build this string on the fly with form data etc. Pretty simple once you know how to do it. Best regards, Jeremy Reed "David Johansen" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Could someone tell me where I could get a basic Authorize.net example to > work off of. I'm sure that I could do it all from scratch, but a base to > start from would be nice and make it a lot faster. Thanks, > Dave > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Forms and String Limitations
I've set up a news database with a PHP front-end and am using MS SQL Server. The news table is set up correctly with the pertinent field being of type 'text' which, according to documentation, should support well over 10 megs of text data. This is the problem: The user tries to submit a news article of 2+ pages (approx 4400 characters) but the article gets truncated to about 4050 characters. Is there some sort of limitation on PHP variables that is causing this? Thanks! Best regards, Jeremy Reed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: PHP Forms and String Limitations
I'm using the POST method. We may be on the right track though, there may have been a problem with the insertion of the data, rather than the retrieval. However, I still don't know what could be causing the problem. "JøRg Vidar Bryne" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > "Jeremy Reed" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > This is the problem: The user tries to submit a news article of 2+ pages > > (approx 4400 characters) but the article gets truncated to about 4050 > > characters. Is there some sort of limitation on PHP variables that is > > causing this? > > Are you using or ? > > I'm not certain about the details but GET is not useful for handeling large > data, while POST has a default setting of max 2MB pr. request. > > -Jørg > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: setting up a user login with PHP
The easiest way is to use cookies. =CODE http://$SERVER/index2.php";); exit(); } else { header("Location:http://$SERVER/error.html";); } ?> This code takes in input from a form as simple as this: Login: Password: Checks it against the database values using the function 'authenticateUser', returns TRUE or FALSE. If true, sends the user onto the correct page, if false, sends them to some error page. Now, in each other file, you'll need to check the cookies. The values for the cookies are sent automatically by the user's browser. In this particular examples, the cookie variables are named '$cookie_user' and '$cookie_passwd'. You can see in the example how those are set. You will check the cookies using the exact same 'authenticateUser' function. Except in these files, you will use the cookie values as the parameters to the function instead of the form values. Hope this helps. Best regards, Jeremy Reed "Mark Ward" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I've got a mySQL database with usernames and passwords. What's the best way > to allow authorized users to enter my site? I'm having some problems using > the forms properly, they've always been my achilles heel when it comes to > web programming. Any help is appreciated. > > Mark Ward > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Setting Cookies
You are getting that error because you have sent output to the browser BEFORE you try to set the cookie information. When dealing with cookies, it is important to do all processing before sending any output to the browser. Jeremy Reed "Steve Osborne" <[EMAIL PROTECTED]> wrote in message 002b01c181b2$52343700$[EMAIL PROTECTED]">news:002b01c181b2$52343700$[EMAIL PROTECTED]... > I am attempting to use the SetCookie command. I receive the following > error: > > Warning: Cannot add header information - headers already sent by > (reference to current page)... > > At this point I have authenticated the user, and am trying to set the cookie > before redirecting them to the registered users section. Should I be > setting the cookie on the top of the page that I am sending them to? > > Any comments or suggestions would be greatly appreciated. > > Steve Osborne > [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Die
Use IF statements to group code, and only use exit() statements when you want to stop execution/parsing. "Max" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi, > > If I use die or exit() it break execution of php script but also > browswer stop parsing html code. How to avoid this? > > Regards.Max. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Antialiasing with GD..?
Antialiasing is done on a pixel by pixel basis. I'm guessing that you don't want to deal with the lines on that kind of basis, considering that it's a whole lot of work. Check the documentation, a lot of graphics engines/utilities include a way draw antialiased lines. However, if you're hell bent on doing it yourself, a quick and dirty solution is to halve the RGB value of the lightest and the darkest pixel adjacent to the 'edge' of the line. Or, if you want better results at double the cost, add two pixels to the line and only drop the RGB value by a third in each of them. So, for example, if you were antialiasing a black line to a white page, black has an RGB value of (255,255,255) or (1,1,1 -- depending on your graphics suite) and white, of course, is (0,0,0) so the antialiased pixel would be (127,127,127) and would have a grayish look. You throw that on the edge of the line and voila, you have psuedo-antialiasing. "Jan Maska" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi, > I have the following problem: > > Using the database, I create a graph like __.--._.--._/\.__ > In order to keep exact colors and prevent a JPEG detail distortion, I use > PNG format as output. > This has one disadvantage: all lines are rough and I don't know how to > antialias them. > > Can anyone help? > > Thanx-a-lot, > > J.M. AKA Mac > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Sending letter with attaching of the file
You cannot attach a file using the mail() function in PHP. You will have to use a SMTP PHP class or another MIME enabled class to use attachments. Jeremy "Alexandr Klaus" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Help me ! > > For sending a letter I using the mail function in PHP. > How send the letter with attached file? > > -- > Alexandr Klaus > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Can i do this?
However, in your if statement, you need to nest your statements with parenthesis. "Jack Dempsey" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > didn't check your code specifically, but you can definitely have arrays > nested inside of arrays...to see how to print them out use something like > print_r to look at the structure... > > -Original Message- > From: Daniel Alsén [mailto:[EMAIL PROTECTED]] > Sent: Thursday, December 13, 2001 10:12 AM > To: PHP > Subject: [PHP] Can i do this? > > > Hi, > > can i do this? > > $num_vals = array (); > for ($i=0; $i<10; $i++) > { > $shot_count = "SELECT COUNT(*) FROM statistik WHERE > shooter='$shooter_login' && shot_one = '$i' || shooter='$shooter_login' && > shot_two = '$i' || shooter='$shooter_login' && shot_three = '$i' || > shooter='$shooter_login' && shot_four = '$i' || shooter='$shooter_login' && > shot_five = '$i'"; > $result = mysql_query($shot_count); > $num_vals[$i] = mysql_fetch_array($result); > } > > I guess it´s the last row that is troubling - getting an array into an > array. If the code is good - how do i echo the results? > > # Daniel Alsén| www.mindbash.com # > # [EMAIL PROTECTED] | +46 704 86 14 92 # > # ICQ: 63006462 | +46 8 694 82 22 # > # PGP: http://www.mindbash.com/pgp/ # > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Date Formatting/Reading
Got a question, I just noticed your signature, 'earn up to $10 per order selling our PHP Scripts'. Are you paying us to help you out? =) Just messing with ya. Anyway, you'd probably want to use a 'DATE' field. For checking the passing of a month, the easiest way would be to use the getdate() function. You can check the numerical value of the month and day to see if a month has passed. The only thing you might want to be careful is if someone signs up on the 29-31, because February only has 28 days so the days (29-31) would never match up. And of course the same goes for months with 30 days and people who sign up on the 31st. Unfortunately, I do not know of a way to do 'math' with dates to get the 30 day difference. I'm sure that with a little effort, you could write something that will do it. EXAMPLE--- $today = getdate(); $month = $today['month']; $mday = $today['mday']; ///get date from database if ((($month - $dbmonth) == 1) && ($mday == $dbday)) { ///time to renew ///also take into account the transition from December to January, so $month-$dbmonth == -12 } -END- Best regards, Jeremy Reed "Phpgalaxy.Com" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi! =) > > I'm doing a website that will be using a pay-per-month membership > program. There's a field for 'lastpaid' that holds the date the last > paid (sorry to state the obvious). My questions are these: > 1) What would be the best way to format it so PHP can see if it's been > 30 days since it was last paid? > 2) What line of code would be used to check? > 3) Would I set the field type to DATE, DATETIME, TIMESTAMP or soemthing > else? > > Any help you can give would be much appreciated! I woulda taken the time > to study it more in-depth but I'm trying to get as much done on this in > 5 hours as I can. =) > > ~ Tim > > -- > From PHPGalaxy.com, earn up to $10 per order selling our PHP Scripts > and Software on your Site. http://www.phpgalaxy.com/aff/ > > Also, get a fast free POP3 email account, you @php.la at > http://www.phpgalaxy.com/search/ > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: storing line breaks in a database
Are you talking about multiple line input boxes from HTML forms, or from a Visual Basic program (or some other such program)? In both cases, the line breaks are included in the output the form posts. However, when displaying them in HTML the linebreaks are ignored and you'd have to use the tag instead. If you were retrieving them for the VB program, they would display correctly anyway. The character for the line break in normal text files is '\n', the line break for VB and other windows files is '\r\n' (2 characters). Best regards, Jeremy Reed "Robin McKenzie" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > I am storing comments in a MySQL db, and want to know how to include line > breaks from multi-line input boxes. > > Does anyone have any experience of doing this? > > Kind Regards, > > Robin > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: arrays
Well, to do this you'll just have to write a loop that takes in every = pair and converts them into an array of values attached to the tag name. You'll have to parse the input character by character. The following pseudo code might help to explain a bit: // input[x] refers to the character at position x in the string input input = ""; for (x = 0, x is each character in input) { if (input[x] equals "<") { $tagname = getName(x); // returns the tag name, will stop at first white space for (y = x, y is each character in input beginning at pos x) { if (input[y] equals " ") { continue; //skips white space } else if (input[y] equals "=") { $value = getValue(y); //returns value beginning and ending with quotes addToArray($tagname, $paramname, $value); //adds the parsed values to an array } else { $paramname = getParam(y); // returns param name up to whitespace or '=' sign. } } } "Php Dood" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I'm trying to figure out how to parse an xml document, and convert it into > html... > i know how to parse in simple xml stuff for example > easy is pretty easy to parse in, and i know how to code that, > but when you start adding flags that i'm going to need variables for, > example easy is not so easy. > > *** > paste sample xml > *** > > > > date="060801" high_temp="24.78" low_temp="14.51" sky_desc="3" > precip_desc="*" temp_desc="8" air_desc="*" uv_index="7" > wind_speed="18.51" wind_dir="270" humidity="48" dew_point="12.01" > comfort="25.28" rainfall="*" snowfall="*" precip_prob="0" icon="2" /> > date="060901" high_temp="20.34" low_temp="13.68" sky_desc="1" > precip_desc="*" temp_desc="7" air_desc="20" uv_index="7" > wind_speed="18.51" wind_dir="270" humidity="57" dew_point="9.23" > comfort="19.23" rainfall="*" snowfall="*" precip_prob="2" icon="1" /> > date="061001" high_temp="20.35" low_temp="12.01" sky_desc="3" > precip_desc="*" temp_desc="7" air_desc="*" uv_index="7" > wind_speed="*" wind_dir="*" humidity="56" dew_point="9.80" > comfort="*" rainfall="*" snowfall="*" precip_prob="1" icon="2" /> > date="061101" high_temp="20.34" low_temp="12.02" sky_desc="3" > precip_desc="*" temp_desc="7" air_desc="*" uv_index="7" > wind_speed="*" wind_dir="*" humidity="57" dew_point="10.34" > comfort="*" rainfall="*" snowfall="*" precip_prob="1" icon="2" /> > date="061201" high_temp="22.01" low_temp="13.12" sky_desc="3" > precip_desc="*" temp_desc="7" air_desc="*" uv_index="7" > wind_speed="*" wind_dir="*" humidity="55" dew_point="11.45" > comfort="*" rainfall="*" snowfall="*" precip_prob="1" icon="2" /> > date="061301" high_temp="23.12" low_temp="13.12" sky_desc="7" > precip_desc="*" temp_desc="7" air_desc="*" uv_index="7" > wind_speed="*" wind_dir="*" humidity="46" dew_point="9.79" > comfort="*" rainfall="*" snowfall="*" precip_prob="2" icon="2" /> > date="061401" high_temp="23.12" low_temp="13.68" sky_desc="7" > precip_desc="*" temp_desc="7" air_desc="*" uv_index="7" > wind_speed="*" wind_dir="*" humidity="49" dew_point="10.34" > comfort="*" rainfall="*" snowfall="*" precip_prob="3" icon="2" /> > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: arrays
Oh, and don't forget to check for the trailing tags i.e. the etc. "Jeremy Reed" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Well, to do this you'll just have to write a loop that takes in every > = pair and converts them into an array of values attached > to the tag name. You'll have to parse the input character by character. > The following pseudo code might help to explain a bit: > > // input[x] refers to the character at position x in the string input > > > input = " unix_date="992001907.00">"; > > for (x = 0, x is each character in input) { > > if (input[x] equals "<") { >$tagname = getName(x); // returns the tag name, will stop at first white > space >for (y = x, y is each character in input beginning at pos x) { > if (input[y] equals " ") { > continue; //skips white space > } else if (input[y] equals "=") { > $value = getValue(y); //returns value beginning and ending with > quotes > addToArray($tagname, $paramname, $value); //adds the parsed values > to an array > } else { > $paramname = getParam(y); // returns param name up to whitespace or > '=' sign. > } >} > } > > > "Php Dood" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > I'm trying to figure out how to parse an xml document, and convert it into > > html... > > i know how to parse in simple xml stuff for example > > easy is pretty easy to parse in, and i know how to code that, > > but when you start adding flags that i'm going to need variables for, > > example easy is not so easy. > > > > *** > > paste sample xml > > *** > > > > > > > > > date="060801" high_temp="24.78" low_temp="14.51" sky_desc="3" > > precip_desc="*" temp_desc="8" air_desc="*" uv_index="7" > > wind_speed="18.51" wind_dir="270" humidity="48" dew_point="12.01" > > comfort="25.28" rainfall="*" snowfall="*" precip_prob="0" icon="2" /> > > > date="060901" high_temp="20.34" low_temp="13.68" sky_desc="1" > > precip_desc="*" temp_desc="7" air_desc="20" uv_index="7" > > wind_speed="18.51" wind_dir="270" humidity="57" dew_point="9.23" > > comfort="19.23" rainfall="*" snowfall="*" precip_prob="2" icon="1" /> > > > date="061001" high_temp="20.35" low_temp="12.01" sky_desc="3" > > precip_desc="*" temp_desc="7" air_desc="*" uv_index="7" > > wind_speed="*" wind_dir="*" humidity="56" dew_point="9.80" > > comfort="*" rainfall="*" snowfall="*" precip_prob="1" icon="2" /> > > > date="061101" high_temp="20.34" low_temp="12.02" sky_desc="3" > > precip_desc="*" temp_desc="7" air_desc="*" uv_index="7" > > wind_speed="*" wind_dir="*" humidity="57" dew_point="10.34" > > comfort="*" rainfall="*" snowfall="*" precip_prob="1" icon="2" /> > > > date="061201" high_temp="22.01" low_temp="13.12" sky_desc="3" > > precip_desc="*" temp_desc="7" air_desc="*" uv_index="7" > > wind_speed="*" wind_dir="*" humidity="55" dew_point="11.45" > > comfort="*" rainfall="*" snowfall="*" precip_prob="1" icon="2" /> > > > date="061301" high_temp="23.12" low_temp="13.12" sky_desc="7" > > precip_desc="*" temp_desc="7" air_desc="*" uv_index="7" > > wind_speed="*" wind_dir="*" humidity="46" dew_point="9.79" > > comfort="*" rainfall="*" snowfall="*" precip_prob="2" icon="2" /> > > > date="061401" high_temp="23.12" low_temp="13.68" sky_desc="7" > > precip_desc="*" temp_desc="7" air_desc="*" uv_index="7" > > wind_speed="*" wind_dir="*" humidity="49" dew_point="10.34" > > comfort="*" rainfall="*" snowfall="*" precip_prob="3" icon="2" /> > > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]