Re: [PHP] PHP, Javascript, and Forms
I think a better way for you to go(it may be a little bit more difficult, but it won't have any annoying flickering from the reloading of page) is to use AJAX. But if you insist on going on a PHP form + Javascript validation - submit form -PHP form + Javascript validation, that can be done as well. It might help to put up a sniplet of your PHP code. When you say the page is reloading, I assume that you mean you have a form tag that sends the POST data back to itself? Beauford wrote: Hi, I have a form with about 20 fields in it and have two drop down menus in which the second one changes depending on the previous one. This is done with a javascript which reloads the page. The problem with this is that everything the user has put in so far gets erased when the page reloads. I am using PHP sessions, but at this point these fields are not saved yet. Is there a way to do this using sessions, or some other PHP function. All the javascript I've looked at reloads the page. This also screws up my validation routines. Thanks B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] url query problem
You've tried accessing $_GET in reservation.php? Like $_GET['client'] would return apartment1 in reservation.php if you clicked on http://www.taximauritius.mu/reservation.php?client=apartment1 -Minuk Imroz wrote: Hi PHP Gurus Am new to the php world, I need help to do something. PlZz help I have this link http://www.taximauritius.mu/link1.php. What I want to do : When clicking on the link above, that would bring me to a page http://www.taximauritius.mu/reservation.php?client=apartment1, and in this URL, as can be seen, there is a variable called apartment1. I want to get the name of this variable + other form fields in my email message when the form is sent. Actually I do get the other form fields in my email message. I just don’t get the variable (client=apartment1) Am attaching the codes, It would really be grateful if you could plzzz help me. Thanks a lot for helping Imrose -- Outgoing mail is certified Virus Free. Checked by AVG Anti-Virus (http://www.grisoft.com). Version: 7.0.269 / Virus Database: 264.8.0 - Release Date: 9/6/2004 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PEAR on PHP 5+?
Thanks! It turns out there was an rpm installed php-4.2.3 which was clobbering with my PHP-5.0.5 installation. I removed it with apt-get remove php and reinstalled PHP-5.0.5 and pear works fine! Thanks again! -Minuk M wrote: Minuk Choi wrote: I can't seem to get pear to work correctly. if I type [/]# pear install DB I get the usage printed out back(no error message, no action) and if I go to the PHP-5.0.4/lib/php directory, I get [PHP-5.0.4/lib/php]# pear install DB br / bFatal error/b: Call to undefined function: getoptions() in b/usr/bin/pear/b on lineb34/bbr / I tried with PHP-5.0.3 and PHP-5.0.2 with the same result. With some google-assisted digging, I found that PEAR/Command.php doesn't have a getOptions function defined... but instead of me trying to overwrite a file or two, I'd like to ask this question Is PEAR broken with PHP5? I mean, I tried re-installing it... (only PHP-5.0.2 - PHP-5.0.4) and pear or pearcmd.php doesn't work. It worked fine for PHP 4, so I'm a little surprised. Any insight? do you have only php5 version installed? If you execute $ php -v what version do you get? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Determining Built Configuration
can you get the output from phpinfo()? That is, create a file, phpinfo.php with the following ?PHP echo phpinfo(); ? and then put that in your htdocs/html directory so you can browse it with your internet browser... there should be a configure block on that page with all the options listed -Minuk [EMAIL PROTECTED] wrote: I need to rebuild PHP on a Linux box (RHEL). It has been built there before but I cannot locate the proper command line for configure -- config.status is no longer accurate as configure was run with no arguments. Is the old configure command line saved in a log somewhere? If not is there a simple way to sort out the options that were used to build the current version? This is PHP 4.3.4 running as part of an Apache 1.3.x static build and also a CLI version. Thanks, -- Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PEAR on PHP 5+?
I can't seem to get pear to work correctly. if I type [/]# pear install DB I get the usage printed out back(no error message, no action) and if I go to the PHP-5.0.4/lib/php directory, I get [PHP-5.0.4/lib/php]# pear install DB br / bFatal error/b: Call to undefined function: getoptions() in b/usr/bin/pear/b on lineb34/bbr / I tried with PHP-5.0.3 and PHP-5.0.2 with the same result. With some google-assisted digging, I found that PEAR/Command.php doesn't have a getOptions function defined... but instead of me trying to overwrite a file or two, I'd like to ask this question Is PEAR broken with PHP5? I mean, I tried re-installing it... (only PHP-5.0.2 - PHP-5.0.4) and pear or pearcmd.php doesn't work. It worked fine for PHP 4, so I'm a little surprised. Any insight? Minuk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Convert fake Unicode to real UTF-8
Have you tried feeding that through htmlentities()? e.g. echo htmlentities(#1043;#1072;); see if that outputs what you want on the page. -Mk Andreas Jakl wrote: I've been searching for quite some time now and tried several functions, but didn't find a solution. I hope somebody can point me in the right direction. The problem: Russian text is entered through a web form. It's a rather badly administrated external webserver with old versions of everything, so I can not set the table to UTF-8. In the MySQL-Table the text gets converted to something like #1043;#1072; as an ASCII text. Using PHP I need to get the text out into a plain text file, as a real UTF-8 string. How can I convert this? All the conversion methods from PHP that I tried failed, as the text seems to really consist of the individual ASCII chars like , #. Therefore, a normal to-unicode-conversion doesn't change anything. Thanks in advance, Andreas Jakl -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [DONE] Substr by words
Good job! However, let me give a few suggestions to optimize the code function trim_text($text, $count) { $text = str_replace( , , $text); /* * This is redundant; you are replacing all in $text with * maybe you meant * $text = trim($text); ? */ $string = explode( , $text); /* * For better programming practice, you should initialize $trimed * I believe if you turn on error_reporting for all in php.ini * PHP will display all warnings and errors. */ for ( $wordCounter = 0; $wordCounter = $count;wordCounter++ ) /* * Typo - you forgot the $ for wordCounter++ * * for ( $wordCounter = 0; $wordCounter = $count; $wordCounter++) */ { $trimed .= $string[$wordCounter]; if ( $wordCounter $count ) { $trimed .= ; } else { $trimed .= ...; } } $trimed = trim($trimed); return $trimed; } This is purely my suggestion... and I'm not saying it is better... but if I were you, I'd do it this way : function trim_text($text, $count) { $text = trim($text); $string = explode( , $text); $trimed=''; for ( $wordCounter = 0; $wordCounter = $count; $wordCounter++ ) { $trimed .= $string[$wordCounter].' '; } $trimed = trim($trimed); if (count($string)$count) $trimed.='...'; return $trimed; } The only difference(not that you'd notice in a lightweight routine like this) is that, I don't have that if-else block inside the loop. Danny wrote: Finally i found it (Google is god, you only have to ask the right question) function trim_text($text, $count){ $text = str_replace( , , $text); $string = explode( , $text); for ( $wordCounter = 0; $wordCounter = $count;wordCounter++ ){ $trimed .= $string[$wordCounter]; if ( $wordCounter $count ){ $trimed .= ; } else { $trimed .= ...; } } $trimed = trim($trimed); return $trimed; } Usage $string = one two three four; echo trim_text($string, 3); -- Forwarded message -- From: Danny [EMAIL PROTECTED] Date: Oct 29, 2005 1:36 PM Subject: Substr by words To: php-general@lists.php.net Hi, I need to extract 50 words more or less from a description field. How can i do that?. Substr, cuts the words. Is there any other way to that, without using and array? I mean and implemented function in PHP 4.x I´ve been googling around, but wordwrap, and substr is driving me mad... Thanks in advance Best Regards -- dpc -- dpc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Processing two post values
...not quite sure what you're asking. Are you asking for help on how to process these variables? I wrote this off the top of my head... meaning that I did not test it... since I don't know if this was what you were asking... I just fiddled with it. Add this code and tell me if it prints out the sql statements the way you wanted BTW, I think your code is wrong here form action=?php action=?php echo $frm['action']; ?property_id=?php echo $_GET['property_id']; ? method=post should be form action=?php echo $frm['action'];?property_id=?php echo $_GET['property_id']; ? method=post -Minuk BEGIN CODE $roomArray = array(); $roomArray['bedroom'] = array(); $roomArray['bathroom'] = array(); $roomArray['reception']=array(); /* * I am assuming all you have are 3 types of rooms, 'bedroom', 'bathroom', and 'reception' * * I am also assuming that the lowest room number is 1 and that the all the room values are of the following format : * * ROOMNAME_ROOMNUMBER_X * ROOMNAME_ROOMNUMBER_Y * * the format is strict, there must be an _ after the room name and one after room number */ /* * Loop through post, and if the form name starts with a room name... then try to decipher the form name. * If appropriate, then add. */ foreach ($_POST as $key=$value) { /* * see if the $key has _ after the first character * and another _ after the first one * * Search for the following * * Valid form names are of * *CHARACTER + (1 or more letters) + _ + NUMBER + (1 or more numbers) + _ + (X or Y) * * Using explode, if we break a form name at the '_', the valid types should break into three pieces *room name *room number *room dimension(x or y) */ $roomDataArray = explode('_', $key); if (count($roomDataArray)==3) { $roomName = $roomDataArray[0]; $roomNumber = $roomDataArray[1]; $roomDimension = $roomDataArray[2]; /* * check to see if $roomName exists in $roomArray, * $roomNumber is a number * $roomDimension is 'X' or 'Y' * $_POST[$key] is a number 0 */ if (isset($roomArray[$roomName]) is_numeric($roomNumber) (strcasecmp($roomDimension, 'x') == 0 || strcasecmp($roomDimension, 'y')==0) is_numeric($_POST[$key]) ) { if (!isset($roomArray[$roomName][$roomNumber])) $roomArray[$roomName][$roomNumber] = array(); $roomArray[$roomName][$roomNumber][$roomDimension] = $value; //By the way, $_POST[$key] = $value, in case I lost 'ya there } } } /* * At this point, $roomArray should be of the following format * * $roomArray['bedroom'][1][x] = 10; * $roomArray['bedroom'][1][y] = 20; * . * . * . * etc. * * generate an insert sql statement PER ROOM */ echo 'sql commands BRBR'; foreach ($roomArray as $roomName=$roomNumberDataArray) foreach ($roomNumberDataArray as $roomNumber=$roomDimensionArray) foreach ($roomDimensionArray as $roomDimension = $value) { $sql = 'insert into database.table(roomName, roomNumber, roomDimensionName, roomDimensionValue) values ('.$roomName.', '.$roomNumber.', '.$roomDimension.', '.$value.');'; echo $sql.'BR'; } echo 'done'; END CODE Shaun wrote: Hi, I have a form on my site with a database driven amount of rooms for a property - bedrooms, bathrooms and receptions. For each room there will be a textfield allowing users to enter the x and y dimensions. For each room I need to insert the values to the database, however I cant think of a way to do this. All one can do with php is a foreach on the $_POST values whereas I need to process two at a time i.e. one insert of the x and y values per room. Here is the form I have created: form action=?php action=?php echo $frm['action']; ?property_id=?php echo $_GET['property_id']; ? method=post table tr ?php $i = 1; while( $i = $frm[Number_Of_Bedrooms] ){ ? tr tdBedroom ?php echo $i ? tdX:input name=bedroom_?php echo $i ?_x type=text //td tdY:input name=bedroom_?php echo $i ?_y type=text //td /tr ?php $i++; } $i = 1; while( $i = $frm[Number_Of_Bathrooms] ){ ? tr tdBathroom ?php echo $i ? tdX:input name=bathroom_?php echo $i ?_x type=text //td tdY:input name=bathroom_?php echo $i ?_y type=text //td /tr ?php $i++; } $i = 1; while( $i = $frm[Number_Of_Receptions] ){ ? tr tdReception ?php echo $i ? tdX:input name=reception_?php echo $i ?_x type=text //td tdY:input name=reception_?php echo $i ?_y type=text //td /tr ?php $i++; } ? tr tdnbsp;/td tdinput type=submit name=Submit value=? echo $frm[submit_text]; ?/td tdnbsp;/td /tr /table /form -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SCRIPT_NAME
... what, the off by one error? Hey, I was just providing suggestion off the top of my head. :-P -Minuk Robert Cummings wrote: On Thu, 2005-10-20 at 23:27, Minuk Choi wrote: Off the top of my head... $filename = $_SERVER['PHP_SELF']; $strippedFilename = substr($filename, strrpos($filename, '/')); Won't work, I'll leave the reason as an exercise :B Cheers, Rob. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SCRIPT_NAME
Off the top of my head... $filename = $_SERVER['PHP_SELF']; $strippedFilename = substr($filename, strrpos($filename, '/')); references : http://us3.php.net/substr http://us3.php.net/manual/en/function.strrpos.php -Minuk John Taylor-Johnston wrote: SCRIPT_NAME and PHP_SELF always include leading url information and slashes. Is there a function I can use to skin either down to the filename? No slashes or leading url. John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] re: some problems with php form
Can you post your Contact_Form_test.php? input class=?PHP if ($error_msg) { echo input.error; } else { echo input.normal; } ? id=firstname name=firstname type=text value=?PHP echo $_POST['firstname'];? should parse into HTML by PHP. This block, I am assuming is placed in a HTML tag and not in a ?PHP block, correct? Bruce Gilbert wrote: Minuk, your revisions gives me an error: *Parse error*: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in * /hsphere/local/home/bruceg/inspired-evolution.com/Contact_Form_test.phphttp://evolution.com/Contact_Form_test.php * on line *63* -Bruce On 10/17/05, Minuk Choi [EMAIL PROTECTED] wrote: Wait a minute... you meant input class= ?PHP if ($error_msg) { echo input.error; } else { echo input.normal; } ? id=firstname name=firstname type=text value=?PHP echo $_POST['firstname'];? ...or am I looking at the wrong thing? Bruce Gilbert wrote: -- Forwarded message -- From: Richard Lynch [EMAIL PROTECTED] To: Mark Rees [EMAIL PROTECTED] Date: Mon, 17 Oct 2005 15:12:50 -0500 (CDT) Subject: Re: [PHP] Re: a couple of problems with PHP form On Mon, October 17, 2005 5:32 am, Mark Rees wrote: - sorry, my editor has not indented again - also, I want the field to appear hilighted when there is no information so I am doing this: input class=? if($error_msg){ echo error; } ELSE { echo normal; } id=firstname name=firstname type=text value={$_POST['firstname']}? / I think the quote mark balancing is messed up here... input class= this starts a quote for the class= There appears to be no ending quote for that... It may simply have been lost in email editing, however... adding the input.error didn't solve the problem dang it.! If there is a ending quote missing, I don't see it right off hand. I know have: input class=? if($error_msg){ echo input.error; } ELSE { echo input.normal; } id=firstname name=firstname type=text value={$_POST['firstname']}? / in the css: input.error { border: 2px inset red; margin:0; font-family: arial, helvetica, sans-serif; color: #036; width: 15em; padding-left: .25em; font-weight: bold; background: #eee; } -- ::Bruce:: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] re: some problems with php form
PROTECTED]; $subject =There has been a disturbance in the force; $mailheaders =From: Inspired-Evolution.com http://www.inspired-evolution.com\n http://www.inspired-evolution.com/n ; $mailheaders .=Reply-To: {$_POST['email']}\n; //send the mail mail ($to, $subject, $msg, $mailheaders); //display information to user echo pHola, strong$firstname/strong!.br /br / We have received your request for a web site review , and will respond shortly.br / Thanks for visiting inspired-evolution.com http://inspired-evolution.comand have a wonderful day!br /br / Regards,br /br / strongInspired Evolution/strong/p; } } ? /end PHP form code*/ On 10/18/05, Minuk Choi [EMAIL PROTECTED] wrote: Can you post your Contact_Form_test.php? input class=?PHP if ($error_msg) { echo input.error; } else { echo input.normal; } ? id=firstname name=firstname type=text value=?PHP echo $_POST['firstname'];? should parse into HTML by PHP. This block, I am assuming is placed in a HTML tag and not in a ?PHP block, correct? Bruce Gilbert wrote: Minuk, your revisions gives me an error: *Parse error*: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in * /hsphere/local/home/bruceg/inspired-evolution.com/Contact_Form_test.phphttp://evolution.com/Contact_Form_test.php http://evolution.com/Contact_Form_test.php * on line *63* -Bruce On 10/17/05, Minuk Choi [EMAIL PROTECTED] wrote: Wait a minute... you meant input class= ?PHP if ($error_msg) { echo input.error; } else { echo input.normal; } ? id=firstname name=firstname type=text value=?PHP echo $_POST['firstname'];? ...or am I looking at the wrong thing? Bruce Gilbert wrote: -- Forwarded message -- From: Richard Lynch [EMAIL PROTECTED] To: Mark Rees [EMAIL PROTECTED] Date: Mon, 17 Oct 2005 15:12:50 -0500 (CDT) Subject: Re: [PHP] Re: a couple of problems with PHP form On Mon, October 17, 2005 5:32 am, Mark Rees wrote: - sorry, my editor has not indented again - also, I want the field to appear hilighted when there is no information so I am doing this: input class=? if($error_msg){ echo error; } ELSE { echo normal; } id=firstname name=firstname type=text value={$_POST['firstname']}? / I think the quote mark balancing is messed up here... input class= this starts a quote for the class= There appears to be no ending quote for that... It may simply have been lost in email editing, however... adding the input.error didn't solve the problem dang it.! If there is a ending quote missing, I don't see it right off hand. I know have: input class=? if($error_msg){ echo input.error; } ELSE { echo input.normal; } id=firstname name=firstname type=text value={$_POST['firstname']}? / in the css: input.error { border: 2px inset red; margin:0; font-family: arial, helvetica, sans-serif; color: #036; width: 15em; padding-left: .25em; font-weight: bold; background: #eee; } -- ::Bruce:: -- ::Bruce:: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] re: some problems with php form
Wait a minute... you meant input class= ?PHP if ($error_msg) { echo input.error; } else { echo input.normal; } ? id=firstname name=firstname type=text value=?PHP echo $_POST['firstname'];? ...or am I looking at the wrong thing? Bruce Gilbert wrote: -- Forwarded message -- From: Richard Lynch [EMAIL PROTECTED] To: Mark Rees [EMAIL PROTECTED] Date: Mon, 17 Oct 2005 15:12:50 -0500 (CDT) Subject: Re: [PHP] Re: a couple of problems with PHP form On Mon, October 17, 2005 5:32 am, Mark Rees wrote: - sorry, my editor has not indented again - also, I want the field to appear hilighted when there is no information so I am doing this: input class=? if($error_msg){ echo error; } ELSE { echo normal; } id=firstname name=firstname type=text value={$_POST['firstname']}? / I think the quote mark balancing is messed up here... input class= this starts a quote for the class= There appears to be no ending quote for that... It may simply have been lost in email editing, however... adding the input.error didn't solve the problem dang it.! If there is a ending quote missing, I don't see it right off hand. I know have: input class=? if($error_msg){ echo input.error; } ELSE { echo input.normal; } id=firstname name=firstname type=text value={$_POST['firstname']}? / in the css: input.error { border: 2px inset red; margin:0; font-family: arial, helvetica, sans-serif; color: #036; width: 15em; padding-left: .25em; font-weight: bold; background: #eee; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Funky array question
Assuming that you are also accepting partial matches... (e.g. if you had a sentence with something like, Mr. LeBlue says hello, and that should be a match for blue) If $mysqlString contains 1 sentence from the mySQL database(I assume you've a loop or something that'll fetch 1 string per iteration) $resultStr = $mysqlString; $bFound=false; foreach ($myArray as $colorArray) { $firstTerm = $colorArray[0]; $secondTerm = $colorArray[1]; if (strpos($resultStr, $firstTerm)!==false) { $resultStr = $secondTerm; $bFound=true; } if ($bFound) break; } $mysqlString = $resultStr; Try that. Brian Dunning wrote: I want to create an array like this: $myArray=array( array('orange','A very bright color'), array('blue','A nice color like the ocean'), array('yellow','Very bright like the sun') ...etc... ) Sort of like a small database in memory. Then I want to compare each of the rows coming out of a MySQL call, which are sentences, against this array to see if the FIRST TERM in each array element is present in the sentence, and then display the SECOND TERM from the array for each sentence. Make sense? So for these two sentences, and the above array, here's how I want it to output: He used blue paint - A nice color like the ocean. The flower was yellow - Very bright like the sun. Can someone help me out with the code needed to search the sentence to which FIRST TERM appears in it, and retrieve the SECOND TERM? I've tried too many things and now my brain is tied in a knot. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with Javascript:...submit()
I'm just taking a wild guess... but I'm guessing that if you set a name with spaces, it'll be replaced with _(underscore). A couple of ways around this is to 1) figure out a way to assign a one-word name for all your books(e.g. Code, ID number, etc.) 2) generate a hash code(e.g. md5($row['LITERATURE_title'])) will generate a one word(no spaces). If this is going to be a library application, you can always use ISBNX(no spaces, no dashes), since the idea is that every book has a unique ISBN number Johan Grobler wrote: while ($row = mysql_fetch_array($sql_result)) { echoForm name=\.$row['LITERATURE_title'].\ action=\searchlit.php\ method=\post\ font face=\arial\ size=\2\ a href=\javascript:.$row['LITERATURE_title']..submit();\ .$row['LITERATURE_title']. - .$row['res_fname']. .$row['res_lname']./a ... Everything works as long as $row['LITERATURE_title'] is one word, see this variable contains the names of books, and if the books name is Heaven for instance it works fine but as soon as the title is something like PHP for Dummies it doesnt work and i get a error on page message, I tried using numbers as the form name but then the same thing happens. Any ways around this? thanx Disclaimer This e-mail transmission contains confidential information, which is the property of the sender. The information in this e-mail or attachments thereto is intended for the attention and use only of the addressee. Should you have received this e-mail in error, please delete and destroy it and any attachments thereto immediately. Under no circumstances will the Cape Peninsula University of Technology or the sender of this e-mail be liable to any party for any direct, indirect, special or other consequential damages for any use of this e-mail. For the detailed e-mail disclaimer please refer to http://www.ctech.ac.za/polic or call +27 (0)21 460 3911 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Query - Warning: Cannot modify header information
Months ago when I kept encountering that problem, it was due to this. Suresh, in /home/gift1/public_html/home.php, do you have a space, an empty line, etc. ? that file should start with ?PHP NOT ?PHP or ?PHP I put double quotes to emphasize that there should be NOTHING before the PHP script start. -Mk Suresh Pandian wrote: Hi friends, i am currently redesign th x-cart site. ichanged the template files into my concern. i received some warnings like this.. Warning: Cannot modify header information - headers already sent by (output started at /home/gift1/public_html/home.php:2) in /home/gift1/public_html/referer.php on line 61 The images in the database also not displayed.but, i didnot change anything in the image.php. how can i solve this .i need help asap - Yahoo! India Matrimony: Find your partner now. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Redirect after download
have you considered attempting to use header(Location: .$URL); where $URL contains the URL AFTER putting ob_start(); at the top of the php file? - Original Message - From: Justin England [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, December 01, 2004 4:07 AM Subject: [PHP] Redirect after download I am writing a file download system and I need to be able to do a redirect after the download is finished. Basically, the user will be presented with a simple HTML page that contains a link to download the file (href=/download.php?fileid=143). I have the code to send the file working just fine, but I can not figure out how to do a redirect after the download is complete. I have spent the last hour searching the archives, and the closest I have found is: http://marc.theaimsgroup.com/?l=php-generalm=106128750620349w=2 But I can't seem to find a way to actually do a Location style redirect. Even static HTML does not display the way one would expect. Using a small text file to download, I can view source from NS and see the everything that was sent to the browser, and everything is there (the ---Boundary(s), the text file, and the simple HTML line). So my question is: How can I perform a redirect after the file has been sent. Thanks, Justin Here is a snippit of download.php (send_file() was found reading the comments to the fread function in the PHP documention): header(Content-Type: multipart/mixed; boundary=\-Boundary-12399\); if(!send_file($file)) { die(File transfer failed!); exit; }else{ print(\n); print(---Boundary-12399\r\n); print(Content-Type: text/html\r\n); print(\r\n); print htmlheadtitleSuccess/title/headbodybFile transfer s uccessful!/b/body/html; print(\r\n---Boundary-12399\r\n); print(\r\n); exit; } function send_file($file) { // read file and send to user $status = FALSE; if ( (!is_file($file['filelocation'])) or (connection_status()!=0) ) return(FALSE); print(---Boundary-12399\r\n); print(Content-type: application/octet-stream\r\n); print(Content-Disposition: inline; filename=\ . $file['filename'] . \\r\n); print(Content-length: . $file['filesize'] . \r\n); print(Expires: . gmdate(D, d M Y H:i:s, mktime(date(H)+2, date(i), date(s), date(m), date(d), date(Y) ) ) . GMT\r\n); print(Last-Modified: . gmdate(D, d M Y H:i:s). GMT\r\n); //print(Cache-Control: no-cache, must-revalidate\r\n); //print(Pragma: no-cache\r\n); if ($fh = fopen($file['filelocation'], 'rb')) { while(!feof($fh) and (connection_status()==0)) { print(fread($fh, 1024*8)); flush(); } $status = (connection_status()==0); fclose($fh); } return($status); } -- 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
Re: [PHP] fedora core 3 mail() not working from web
Thanks Curt. I decided after a while to chalk this up as incomplete installation of Fedora Core 3, and just removed the Apache-PHP-MySQL RPMs and replaced them with their sources. I compiled them and now everything works! NOTE: Since re-installing those three fixed the problem, there was no issue with Sendmail, probably just with PHP/Apache. - Original Message - From: Curt Zirzow [EMAIL PROTECTED] To: PHP [EMAIL PROTECTED] Sent: Thursday, November 25, 2004 2:54 PM Subject: Re: [PHP] fedora core 3 mail() not working from web * Thus wrote Minuk Choi: hey gang, I have a fedora core 3, with standard PHP and MySQL included with the distribution. I'm having a rather odd problem. the following script(mailTest.php) ?PHP $result = mail('[EMAIL PROTECTED]', 'test subject', 'test message'); if (!$result) echo FAILURE; else echo SUCCESS; ? does NOT work if I access it from the web BUT if I were to execute it as root on the Command prompt php mailTest.php It executes correctly and I get mail. This feels like the apache user is lacking access over sendmail or something... since as root I can execute the script from the CLI without a problem, but from the web, I get a failure. You're probably on the right track with this. Check your php.ini settings for sendmail_path. Also.. the default setting for sendmail_path is 'sendmail -t -i' so if sendmail isn't in the path for your webuser then it wont get executed. To fix this, specifiy in you php.ini with the sendmail_path the absolute sendmail executable. ie: sendmail_path = /usr/sbin/sendmail -t -i HTH, Curt -- Quoth the Raven, Nevermore. -- 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
Re: [PHP] fedora core 3 mail() not working from web
The weirdest thing was that there was NO error message. Even though in the php.ini, I set the error reporting to E_ALL, I got no warnings, notices, or failures. I removed the RPMs and compiled the sources and now they work... so I guess the problem was due to a incomplete installation of those RPMs off the Fedora Core 3 CDs... - Original Message - From: Angelo Zanetti [EMAIL PROTECTED] To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Friday, November 26, 2004 7:50 AM Subject: Re: [PHP] fedora core 3 mail() not working from web Hi, It could have something to do with your PHP.ini file?? Can you post the error message, as it will give us a better idea of what could be wrong. Angelo Minuk Choi [EMAIL PROTECTED] 11/26/2004 10:31:59 AM hey gang, I have a fedora core 3, with standard PHP and MySQL included with the distribution. I'm having a rather odd problem. the following script(mailTest.php) ?PHP $result = mail('[EMAIL PROTECTED]', 'test subject', 'test message'); if (!$result) echo FAILURE; else echo SUCCESS; ? does NOT work if I access it from the web BUT if I were to execute it as root on the Command prompt php mailTest.php It executes correctly and I get mail. This feels like the apache user is lacking access over sendmail or something... since as root I can execute the script from the CLI without a problem, but from the web, I get a failure. Can anyone shed a light as to what settings I need to tweak PHP so mail() can work? Thanks -Minuk Disclaimer This e-mail transmission contains confidential information, which is the property of the sender. The information in this e-mail or attachments thereto is intended for the attention and use only of the addressee. Should you have received this e-mail in error, please delete and destroy it and any attachments thereto immediately. Under no circumstances will the Cape Technikon or the sender of this e-mail be liable to any party for any direct, indirect, special or other consequential damages for any use of this e-mail. For the detailed e-mail disclaimer please refer to http://www.ctech.ac.za/polic or call +27 (0)21 460 3911 -- 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] fedora core 3 mail() not working from web
hey gang, I have a fedora core 3, with standard PHP and MySQL included with the distribution. I'm having a rather odd problem. the following script(mailTest.php) ?PHP $result = mail('[EMAIL PROTECTED]', 'test subject', 'test message'); if (!$result) echo FAILURE; else echo SUCCESS; ? does NOT work if I access it from the web BUT if I were to execute it as root on the Command prompt php mailTest.php It executes correctly and I get mail. This feels like the apache user is lacking access over sendmail or something... since as root I can execute the script from the CLI without a problem, but from the web, I get a failure. Can anyone shed a light as to what settings I need to tweak PHP so mail() can work? Thanks -Minuk
Re: [PHP] page redirect question
Victor, try this. at the TOP of your HTML, put ?PHP ob_start(); ? then you can have all your regular HTML/PHP/JAVASCRIPT/ETC code, and somewhere(in the middle, in the end), you can call ?PHP header('location: '.$URL); ? where $URL is a variable that contains a URL and it will work. ? - Original Message - From: Victor C. [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, November 09, 2004 11:07 AM Subject: [PHP] page redirect question Hi, Is there anyway to redirect php page other than using HEADER(LOCATION:URL) ? Header can only be called if nothing is written to HTML... Is there anyway around it? Thanks, -- 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
Re: [PHP] Video Uploads
How big are the video files(byte wise)? Have you tried uploading a non-video file of the same size? - Original Message - From: Jay Fitzgerald [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, November 09, 2004 12:10 PM Subject: [PHP] Video Uploads I can upload just about everything with this script; but I don't understand why it says that the videos i try to upload are zero length. -- THE FORM -- form method=post name=info enctype=multipart/form-data id=x-form action=add.php input type=hidden name=max_size value=5120 input type=file name=form_data input type=submit name=submit value=Add Video/form -- THE SCRIPT -- ini_set ('display_errors', '1'); ini_set ('error_reporting', E_ALL); if (empty($_POST['submit'])) { include ('addform.php'); } else { $path = '/home/mydir/public_html/news/videos/'.$_FILES['form_data']['name']; $url = 'http://www.mysite.com/news/videos/'; $_POST = array_merge($_POST, $_FILES); if (!empty($_FILES['form_data']['name'])) { if ($_FILES['form_data']['size'] == 0) { echo 'Problem: '.$_FILES['form_data']['name'].' is zero length'; } if ($_FILES['form_data']['size'] $_POST['max_size']) { echo 'Problem: '.$_FILES['form_data']['name'].' is over '.$_POST['max_size'].' bytes.'; } if (!is_uploaded_file($_FILES['form_data']['tmp_name'])) { echo $_FILES['form_data']['name'].' is not uploaded.'; } move_uploaded_file($_FILES['form_data']['tmp_name'], $path); } } -- 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
Re: [PHP] problem with array
You say you have a database with many CHAR(60) fields? Have you considered changing those to VARCHAR(60)? This isn't PHP and is probably inappropriate solution(since it is not PHP related), but I believe a CHAR(60) defines the field as a fixed length character string, meaning no matter what you want to store, it is 60 lengths. VARCHAR(60) is a variable length(still fixed, since you have a maximum) length field type. My SQL datatypes may be rusty, but try converting a small portion of your db to VARCHAR(60) and try pulling data off those fields. Let me know how it turns out. -Minuk - Original Message - From: Dale Hersowitz [EMAIL PROTECTED] To: 'Minuk Choi' [EMAIL PROTECTED] Sent: Tuesday, October 19, 2004 12:38 AM Subject: RE: [PHP] problem with array Minuk, After much searching and asking, I found the answer to my problem. It turns out that after re-attaching my db and re-formatting the server, the db has been slightly adjusted. Let me explain. Many of my fields are set to char with a width of 60. As a result, when I extract data from the db, it has extra chars or blank spaces attached to it. I am finding myself to have to use the trim function everywhere. If you have a fix to this problem it would be greatly appreciated. Thx. Dale Hersh Corporation 2250 E. Imperial Hwy., 2nd Fl. El Segundo, CA 90245 USA Phone: (310) 563-2155 Fax: (310) 563-2101 E-mail: [EMAIL PROTECTED] Web Site: www.hershonline.com E-Mail Disclaimer NOTE: This e-mail message and all attachments thereto (this message) contain confidential information intended for a specific addressee and purpose. If you are not the addressee (a) you may not disclose, copy, distribute or take any action based on the contents hereof; (b) kindly inform the sender immediately and destroy all copies thereof. Any copying, publication or disclosure of this message, or part thereof, in any form whatsoever, without the sender's express written consent,is prohibited. No opinion expressed or implied by the sender necessarily constitutes the opinion of Hersh Corporation. This message does not constitute a guarantee or proof of the facts mentioned therein. Hersh Corporation accepts no responsibility or liability in respect of (a) any opinion or guarantee of fact, whether express or implied; or (b) any action or failure to act as a result of any information contained in this message, unless such information or opinion has been confirmed in writing by an authorized Hersh Corporation partner or employee. -Original Message- From: Minuk Choi [mailto:[EMAIL PROTECTED] Sent: Friday, October 15, 2004 5:16 PM To: Dale Hersowitz Subject: Re: [PHP] problem with array Hmm... okay, Now, is the output you gave me the last row? That is, that's the row you have errors? According to the output, it should work, since $row['selectedCol'] exists and $row['selectedCol'] = col0 and $row['col0'] exists. How about this approach, tell me what it is you are trying to accomplish from the block of code. In particular, explain to me what $selectedCol=$row[selectedCol]; echo $selectedCol; $selectedColName=$row[$selectCol]; //--- PLEASE NOTE THIS SPECIFIC is supposed to prove. --your code-- $query=SELECT * FROM customizeViewClients WHERE employeeNum = $employeeNum; $results=mssql_query($query, $connection) or die(Couldn't execute query); $numRows=mssql_num_rows($results); if($numRows0) { $row=mssql_fetch_array($results); } $selectedCol=$row[selectedCol]; echo $selectedCol; $selectedColName=$row[$selectCol]; //--- PLEASE NOTE THIS SPECIFIC - Original Message - From: Dale Hersowitz [EMAIL PROTECTED] To: 'Minuk Choi' [EMAIL PROTECTED] Sent: Friday, October 15, 2004 1:29 PM Subject: RE: [PHP] problem with array Minuk, I add that line of code and here is what came out: selectedCol : col0 Array ( [0] = 1 [employeeNum] = 1 [1] = clientName [col0] = clientName [2] = city [col1] = city [3] = telephoneNum [col2] = telephoneNum [4] = telephoneNum2 [col3] = telephoneNum2 [5] = cp1FirstName [col4] = cp1FirstName [6] = 1 [col0Active] = 1 [7] = 1 [col1Active] = 1 [8] = 1 [col2Active] = 1 [9] = 1 [col3Active] = 1 [10] = 1 [col4Active] = 1 [11] = col0 [selectedCol] = col0 [12] = ASC [selectionType] = ASC ) Thx. Dale -Original Message- From: Minuk Choi [mailto:[EMAIL PROTECTED] Sent: Thursday, October 14, 2004 9:04 PM To: Dale Hersowitz Subject: Re: [PHP] problem with array $row['selectedCol'] returns 'clientName'??? let me guess, $row should have a column named 'clientName'? try this and tell me the output. $query=SELECT * FROM customizeViewClients WHERE employeeNum = $employeeNum; $results=mssql_query($query, $connection) or die(Couldn't execute query); $numRows=mssql_num_rows($results); if($numRows0) { $row=mssql_fetch_array($results); } $selectedCol=$row[selectedCol
Re: [PHP] problem with array
$selectedCol=$row[selectedCol]; echo $selectedCol; $selectedColName=$row[$selectCol]; //--- PLEASE NOTE THIS SPECIFIC ROW Please give me the output, what do you get from echo $selectedCol;? If I had to guess, it looks like you're confusing key and value of an associatative array. if $row[selectedCol] = 12; $row[12] does NOT equal SelectedCol. In fact, even if you used mysql_fetch_array, you will not be able to do a reverse lookup like that. Suppose you have the following : $row['a'] = 1; $row['b'] = 2; $row['c'] = 1; You can see that your approach is incorrect because what would $row[1] return? If this is NOT your question, please post your output(errors and all). - Original Message - From: Dale Hersowitz [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, October 14, 2004 9:58 PM Subject: [PHP] problem with array Hi guys, Recently, I had to reformat one of the web servers and now I have encountered an unusual problem. I am not sure whether this is an issue which can be fixed in the .ini file or whether its specific to the version of php I am using. Here is the problem: $query=SELECT * FROM customizeViewClients WHERE employeeNum = $employeeNum; $results=mssql_query($query, $connection) or die(Couldn't execute query); $numRows=mssql_num_rows($results); if($numRows0) { $row=mssql_fetch_array($results); } $selectedCol=$row[selectedCol]; echo $selectedCol; $selectedColName=$row[$selectCol]; //--- PLEASE NOTE THIS SPECIFIC ROW For some reason, on the last row, I am not unable to reference a particular index in the array using a php variable. This has been working for almost 12 months and now the coding is breaking all over the place. I don't have an answer. Any feedback would be greatly appreciated. Thx. Dale -- 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
Re: [PHP] Lost in PHP (part 1) ---- Sequle to Lost in Query
As far as checking to see if it's a number, note that you can get the following 10 = string that contains 10 10 = integer that contains 10. You can verify that a variable contains numbers or numeric data by using if (is_numeric($variable)) { $variable is either a number variable or a string containing only numeric data } HTH -Minuk - Original Message - From: GH [EMAIL PROTECTED] To: John Holmes [EMAIL PROTECTED] Cc: GH [EMAIL PROTECTED]; PHP General [EMAIL PROTECTED] Sent: Tuesday, October 12, 2004 12:00 AM Subject: Re: [PHP] Lost in PHP (part 1) Sequle to Lost in Query Re: Does it _really_ matter if only a number is passed? I would think so since if someone is trying to pass a string that is not proper it should be treated as such and not as if they are just take the first set of numbers and Throw away all the rest. Maybe I am over thinking this or I am being paranoid I am trying to make this work good and hope to design it to be secure since this is my first PHP endevor Thanks G On Mon, 11 Oct 2004 14:02:08 -0400, John Holmes [EMAIL PROTECTED] wrote: GH wrote: How can I convert it to an integer aslong as it is only a number in the string? Does it _really_ matter if only a number is passed? If someone passes abcd and it's converted to an integer, it'll be zero. Then your query will not return any rows (which you're already testing for, anyhow, right?) and be handled accordingly. Who cares if they pass 104abcd? It'll just be converted to 104 and see if a matching record exists. I think you're getting caught up in too many tests. If you're expecting an integer, MAKE it an integer, then run your query. 99.9% of your values are going to come through correct if they are coming from your program, right? Just silently ignore the rest because it's someone screwing around. If, however, you _really_ want to ensure $_GET['api'] is _only_ numbers, then you can use if(!isset($_GET['api']) || preg_match('/[^0-9]/',$_GET['api'])) { echo 'API is not all numbers'; } or if(isset($_GET['api']) preg_match('/^[0-9]+$/',$_GET['api'])) { echo 'API is a number only'; } -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- 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
Re: [PHP] forms
What is a connect_db file? - Original Message - From: bigmark [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, October 10, 2004 11:33 PM Subject: Re: [PHP] forms Thanks-- i got that going-GREAT ! now i have a form that creates the database and tables, any ideas how i can get this info to change the connect_db file so that it doesnt have to be done manually. Minuk Choi [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] try this : $link = mysql_connect($host, $user, $pass); Note : No SINGLE quotes. In PHP, quotations are as follows $host = 'localhost'; $a = '$host'; $b = $host; echo $a; that prints $host echo $b; that prints localhost. HTH -Minuk - Original Message - From: bigmark [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, October 10, 2004 10:23 PM Subject: [PHP] forms/variables/create database hi, does anyone know why this is not working, i have married 2 pieces of code together and i have no idea what im doing--any help is appreciated. I get an error that says it cant find the host--$host so obviusly its not passing it from the form. / ?php $host = $_POST['host']; $user = $_POST['user']; $pass = $_POST['pass']; $db_name = $_POST['db-name']; $link = mysql_connect('$host', '$user', '$pass'); if (!$link) { die('Could not connect: ' . mysql_error()); } if (mysql_create_db('db_name')) { echo Database created successfully\n; } else { echo 'Error creating database: ' . mysql_error() . \n; } ? / -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] install /setup script
Well, you can just put up a regular form, something to the effect of form action=create_db.php method=post Hostname input type=text name=Hostname User Nameinput type=text name=username Password input type=text name=password ... ... ... etc. /form and when you submit that form, those variables will be accessible under the $_POST array such as $hostName = $_POST['Hostname']; $userName=$_POST['username']; etc. NOTE that doing it this way presents several security issues 1) You should add some checking before connecting to the MySQL database; a user can specify mysql as the database and you'd have your tables installed in the mysql database(which is used by mysql for its privilege/user tables and such... I normally make it a practice to NOT mess it with the mysql tables). (e.g. If you plan to drop the database and repopulate it, then specifying mysql for database would destroy MySQL's core tables) 2) If you are not familar with the $_POST array, it is the data that you specified between the form and /form tag. Just like how there is a form method=POST and form method=GET, there is a $_GET array. But many people frown if you have a form that asks for username and password and you submit that via GET(as the values you specified would be appended at the end of the URL). HTH -Minuk - Original Message - From: bigmark [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, October 11, 2004 12:14 AM Subject: [PHP] install /setup script Thanks for the help with the createdb and tables form, now can anyone help with changing the config.php (ie: host,user,password) via a form also-- so that it doesnt have to be done manually within the config script. Basically i want an install/setup page with all the form elements-- Hostname- username- Password- Choose database name- Then it installs the database and tables then redirects to the main site page and the config.php is already configured for them BigMark -- 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
Re: [PHP] Parse Error --- can not solve at this time... please assit
the , $desc) is your culprit. foreach ($arrayVariable as $key=$value) is probably the form you meant. foreach ($admin_get_options_result as $api =$file, $desc) what is $api, $file, $desc supposed to be? If I were to hazard a guess, is the $admin... array a nested array, something like $admin...[$api][$file]=$desc NOTE : your name for $admin... is too long, so I'm writing it as $admin... in case you were wondering If that is the case that you have a nested array, try the following foreach ($admin... as $api = $data) foreach ($data as $file=$desc) { //stuff. } On a unrelated note, in your sniplet, there is no declaration for $admin_get_options_results, perhaps you meant, $admin_get_options_results_reference? Typically, I prefer to have short but meaningful variable names. Yours is kinda long. This is just a personal opinion, but perhaps you should reconsider your naming scheme, as that might save time on any misspelled variable names. HTH -Minuk - Original Message - From: GH [EMAIL PROTECTED] To: PHP General [EMAIL PROTECTED] Sent: Monday, October 11, 2004 1:48 AM Subject: [PHP] Parse Error --- can not solve at this time... please assit With the following code, I am getting the following message Parse error: parse error, expecting `')'' in /var/www/html/cert/admin_template.php on line 30 Line 30 Reads as follows: foreach($admin_get_options_result as $api = $file, $desc) Can any one please assist. ***ENTIRE CODE STARTING AT LINE 1 FOLLOWS * html head titleADMINISTRATION SCREEN/title meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 /head body ?PHP require 'mod/db_access.php'; echo 'this is a test of the system'; if(!isset($_GET['api']) || (isset($_GET['api']) ((strlen(trim(urldecode($_GET['api']))) == 0) || (!is_int($_GET['api']) $_GET['api']=0; if($_GET['api'] == 0) { $admin_get_options_query_text = Select * from Adminpage; $admin_get_options_results_reference = mysql_query($admin_get_options_query_text,$db_access) or die(Admin Get Options: . mysql_error()); $admin_get_options_result = mysql_fetch_assoc($admin_get_options_result_reference); if(mysql_num_rows($admin_get_options_results_reference)0) { ? table width=600 TR TD Link /TD TD DESCRIPTION /TD/TR ?PHP foreach($admin_get_options_result as $api = $file, $desc) { echo 'TR TD'; echo 'a href=#?api'.urlencoded($api).' Click Here /a /td'; echo 'TD'.$desc.'/TD/TR'; } ? /table ?PHP } } else { $admin_get_page_query_text = Select * from Adminpage Where adminpageid = $_GET['api'] LIMIT 1; $admin_get_page_results_reference = mysql_query($admin_get_page_query_text,$db_access) or die(Admin Get Page: . mysql_error()); $admin_get_page_result = mysql_fetch_row($admin_get_page_result_reference); if (mysql_num_rows($admin_get_page_results_reference) 0) { require mod/admin/.trim(strtolower($admin_get_page_result[1])); } else { echo ERROR: Invalid Admin Page Requested br; echo 'Please Try Again ... a href=admin_template.php?api=0 Click Here /a'; } } ? /body /html -- 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
Re: [PHP] Finding one line in a Variable?
If you don't mind NOT using regex or regular expression searching commands, you can try it this way. Assuming that there is a carriage break(e.g. \r\n if windows, and I'm assuming the HTML file was written in windows, otherwise, just \n for Unix and \n\r for Mac, I believe). $eolnString =\r\n; $searchString = the_identifying_string; $result=NOT FOUND; $HTMLDumpArray = explode($eolnString, $myHTML); /* if $myHTML = HTML\r\n\tBODY\r\n\t/BODY\r\n/HTML; then $HTMLDumpArray is now $HTMLDumpArray[0] = HTML; $HTMLDumpArray[1] = \tBODY; $HTMLDumpArray[2] = \t/BODY; $HTMLDumpArray[3] = /HTML; */ foreach ($HTMLDumpArray as $HTMLLine) if (stripos($HTMLLine, $searchString)!==FALSE) //stripos returns the index number of where the $searchString was found OR returns FALSE { $result = $HTMLLine; break; } echo RESULT .$result; try that and let me know if that works. HTH, -Minuk - Original Message - From: Nick Wilson [EMAIL PROTECTED] To: php-general [EMAIL PROTECTED] Sent: Monday, October 11, 2004 3:45 AM Subject: [PHP] Finding one line in a Variable? Hello all, I have to find and put one line of an html file in a variable. I already have the entire html file stored in a variable like this: $myHTML=htmlheadblah blah blah; - Grabbed using cURL The particular line I want will *always* contain the string the_identifying_string So the line itself (the line i want to get into a var) would look like this: form method=post action=blah.php name=the_identifying_string blah.. How can I get that entire line? many thanks, im sure your all bored of my regex woes heh.. but thanks, it's appreciated.. -- Nick W -- 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] testing - disregard
This is a test e-mail, please disregard
Re: [PHP] textarea vs. type=text data difference?
Okay, so in other words... //Doc1.php include functions.php //this file contains the function definition for protectText() include formProcessor.php //this file contains the code that calls protectText() include form.php //this file gets the form data from user By any chance, are ANY of the include files classes? I'm not 100% sure(unless you put up some more code), but it sounds like it's maybe a scope error... especially if you define the function in formProcessor and it works fine... -Minuk - Original Message - From: Sam Smith [EMAIL PROTECTED] To: PHP [EMAIL PROTECTED] Sent: Sunday, October 10, 2004 4:25 PM Subject: Re: [PHP] textarea vs. type=text data difference? ##The data is the same. I've been up a long time. BUT something is still very weird. Doc1.php (loaded in web browser) //contents of Doc1.php include functions.php include formProcessor.php include form.php Calling the protectText() function in functions.php from formProcessor.php with data posted from form.php works on data posted from textarea fields but does NOT on data posted from type=text. //contents of functions.php ONLY works on textarea fields The fundtion in function.php is: function protectText($tv) { $tv = stripslashes($tv); $tv = str_replace(\,[QT],$tv); $tv = str_replace(\r,br,$tv); return $tv; } BUT if I put the same function in formprocessor.php it works!?? //contents of formprocessor.php THIS works on both function TSTprotectText($tv) { $tv = stripslashes($tv); $tv = str_replace(\,[QT],$tv); $tv = str_replace(\r,br,$tv); return $tv; } TSTprotectText($_POST['field']); Now how can that be? Can you be a little more specific on what differences you get? I normally use textarea for multi-line data and input type=text for one line, short data... the only difference you might encounter that I can think off the top of my head is maybe line break? - Original Message - From: Sam Smith [EMAIL PROTECTED] To: PHP [EMAIL PROTECTED] Sent: Sunday, October 10, 2004 3:28 PM Subject: [PHP] textarea vs. type=text data difference? I have a form with both textarea and text type fields. I submit it and do some processing on identical data and get different results. What's up with that. Thank you. -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms/variables/create database
try this : $link = mysql_connect($host, $user, $pass); Note : No SINGLE quotes. In PHP, quotations are as follows $host = 'localhost'; $a = '$host'; $b = $host; echo $a; that prints $host echo $b; that prints localhost. HTH -Minuk - Original Message - From: bigmark [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, October 10, 2004 10:23 PM Subject: [PHP] forms/variables/create database hi, does anyone know why this is not working, i have married 2 pieces of code together and i have no idea what im doing--any help is appreciated. I get an error that says it cant find the host--$host so obviusly its not passing it from the form. / ?php $host = $_POST['host']; $user = $_POST['user']; $pass = $_POST['pass']; $db_name = $_POST['db-name']; $link = mysql_connect('$host', '$user', '$pass'); if (!$link) { die('Could not connect: ' . mysql_error()); } if (mysql_create_db('db_name')) { echo Database created successfully\n; } else { echo 'Error creating database: ' . mysql_error() . \n; } ? / -- 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
Re: [PHP] MYSQL_VERSION_ID?
I wouldn't be too surprised if that is the case. I tried my best to remove the rpm installations and as for the compilation options, I believe I specified them correctly, since I got them to install insto the directories I specified. The more important question to me is how PHP5 gets the value for MYSQL_VERSION_ID, though. - Original Message - From: Curt Zirzow [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, October 09, 2004 2:46 AM Subject: Re: [PHP] MYSQL_VERSION_ID? * Thus wrote Minuk Choi: I've a Redhat9 and installed MySQL 4.0 from source and Apache 1.3 from source. From my expirence, at this point you probably have 2 versions of mysql and 2 versions of apache on your system. Your new versions, depending on how you compile them will default to the paths of: /usr/local/mysql/ /usr/local/apache/ The default installations will be spread accross: /etc/* /usr/include/* /usr/lib/* ... I also downloaded the PHP5.0.2 source and attempted to compile it. Apache and MySQL are installed successfully, as they all work without any noticeable errors. This is how I configured PHP5 ./configure --prefix=/PHP5 --with-mysql=mysql path what exactly is that mysql path you issue? when I ran make, I got an error. It was regarding one of the functions, make tried to compile mysql_create_db and mysql_drop_db(functions that are no longer provided by the MySQL4.0 client). If this is the case then the configuration of php picked up the headers for the old version of mysql, but the libraries that php tried to use where mysql4. Causing the errors. If you provide the exact errors you got when compiling, it might be insightful. When I checked the source code(the c and h files), there was this line, #if MYSQL_VERSION_ID 4 which was enclosed in the declaration of the function prototypes PHP_FUNCTION(mysql_create_db) PHP_FUNCTION(mysql_drop_db) in php_mysql.h and also around the implemention of the functions PHP_FUNCTION(mysql_create_db) PHP_FUNCTION(mysql_drop_db) in php_mysql.c This is correct behaviour. The problem I seem to have is that MYSQL_VERSION_ID is never defined? Perhaps this is due to the fact that I compiled MySQL 4.0 from source and may have skipped a step... but where is MYSQL_VERSION_ID supposed to be defined or retrieved? typing echo $MYSQL_VERSION_ID in bash got me a blank line. the #if MYSQL_VERSION_ID is not defined in your environment but in the header file of mysql_version.h if at your shell prompt you type: locate mysql_version.h You should get a minimum of 2 or possibly 3 files resulted: /path/to/php/src/ext/mysql/libmysql/mysql_version.h /usr/local/mysql/include/mysql_version.h /usr/include/mysql_version.h That is where MYSQL_VERSION_ID is defined. I managed to comment out those functions in the header and the c files and make and make install ran flawlessly. This may work, but dont expect mysql_thread_id() to work and you might run into other side effects depending on what version php is thinking mysql is. Could this be a bug? Doesn't look like it. Curt -- The above comments may offend you. flame at will. -- 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] MYSQL_VERSION_ID?
I've a Redhat9 and installed MySQL 4.0 from source and Apache 1.3 from source. I also downloaded the PHP5.0.2 source and attempted to compile it. Apache and MySQL are installed successfully, as they all work without any noticeable errors. This is how I configured PHP5 ./configure --prefix=/PHP5 --with-mysql=mysql path when I ran make, I got an error. It was regarding one of the functions, make tried to compile mysql_create_db and mysql_drop_db(functions that are no longer provided by the MySQL4.0 client). When I checked the source code(the c and h files), there was this line, #if MYSQL_VERSION_ID 4 which was enclosed in the declaration of the function prototypes PHP_FUNCTION(mysql_create_db) PHP_FUNCTION(mysql_drop_db) in php_mysql.h and also around the implemention of the functions PHP_FUNCTION(mysql_create_db) PHP_FUNCTION(mysql_drop_db) in php_mysql.c The problem I seem to have is that MYSQL_VERSION_ID is never defined? Perhaps this is due to the fact that I compiled MySQL 4.0 from source and may have skipped a step... but where is MYSQL_VERSION_ID supposed to be defined or retrieved? typing echo $MYSQL_VERSION_ID in bash got me a blank line. I managed to comment out those functions in the header and the c files and make and make install ran flawlessly. Could this be a bug? -Mark
Re: [PHP] php5 and php4?
But then, don't you run the risk of having 2 different architectures, that is, PHP5(possibly PHP6) and PHP 4.something may evolve down to include different features or even different behaviors? - Original Message - From: Thomas Goyne [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, September 21, 2004 1:45 AM Subject: Re: [PHP] php5 and php4? On Tue, 21 Sep 2004 01:29:06 -0400, Minuk Choi [EMAIL PROTECTED] wrote: I've been meaning to ask this... but I always thought I could find the answer online(I didn't). Back when PHP 5.0.1 was released, PHP 4.something else was released. What was the main reasoning behind this move? Is it because PHP5 is more OOP(similar to java)? PHP 4 is still being maintained for two reasons: 1) PHP 5 breaks bc (although only in minor ways) 2) Very few people upgrade to a new major version until at least the first point release (5.1). One of the magical things about open source software is that as long as someone still wants something updated, it will continue to be, so php4 will probably be maintained until around when php6 is released. -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ -- 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
Re: [PHP] php5 and php4?
Oh, I see. Thanks for clarifying. - Original Message - From: Matthew Weier O'Phinney [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, September 21, 2004 4:05 PM Subject: Re: [PHP] php5 and php4? * Minuk Choi [EMAIL PROTECTED]: But then, don't you run the risk of having 2 different architectures, that is, PHP5(possibly PHP6) and PHP 4.something may evolve down to include different features or even different behaviors? PHP4 is in *maintenance* mode -- that means no new features. PHP5 may introduce new features, and PHP6 definitely will, but at this point PHP4 will only experience bugfixes and security updates. -- Matthew Weier O'Phinney | mailto:[EMAIL PROTECTED] Webmaster and IT Specialist | http://www.garden.org National Gardening Association| http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org -- 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] php5 and php4?
I've been meaning to ask this... but I always thought I could find the answer online(I didn't). Back when PHP 5.0.1 was released, PHP 4.something else was released. What was the main reasoning behind this move? Is it because PHP5 is more OOP(similar to java)?
[PHP] PHP + Multiple MySQL-4.0.20
I have a RedHat9 machine. I needed to have multiple MySQL installations, so I removed the RPM installation and did a binary installation of MySQL-4.0.20. As it stands, I have the following installations /usr/local/mysql-4.0.20-webpage /usr/local/mysql-4.0.20-exp /usr/local/mysql-4.0.20-def These are all the same BINARY installations of MySQL-4.0.20, I just need to have 3 distinct set of mysql databases(along with their specific custom database/tables). It seems to have worked, as I can get the mysql instances up and running. BUT, I can't seem to make PHP access these databases. More specifically, phpMyAdmin-2.5.6 says cannot load MySQL extension, please check PHP Configuration. Documentation I haven't a clue as to how to resolve this. My guess is, like the MySQL RPM, uninstall it and do a non-RPM install... If I get the source and run configure... it seems like the --with-mysql= field only takes 1 mysql path. What should I do in my case, where there are 3 paths, 3 sockets, and 3 ports on which mysql resides? Thanks in advance, -Minuk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php