Re: [PHP] Re: posting variables to parent frame
Zoltán Németh wrote: Incidentally, br/ is an error for html. can you tell me why br/ is an error greets Zoltán Németh br/ is xhtml. It's not an error in xhtml, but might confuse older browsers. I tried it, even with a strict HTML 4.01 doctype and didn't get any errors, but who knows. I have read that br/ might confuse older browsers, so it is usually written br / to avoid problems. The basic HTML version is br. Lori -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Result problem
Dan Shirah wrote: Okay, print_r($result_record) for the query result. But I still don't know why it's only returning the last record of the query instead of all the results. Because it's a cursor and you're not resetting the position. You can't print the entire result set this way - you have to iterate through the result set in a loop, printing out the row on each iteration. Lori On 4/25/07, Zoltán Németh [EMAIL PROTECTED] wrote: 2007. 04. 25, szerda keltezéssel 16.56-kor Dan Shirah ezt írta: Any ideas why my query only returns the very last record that matches the criteria specified?? $sql_record =SELECT * FROM payment_request WHERE status_code = 'P'; $result_record = mssql_query($sql_record) or die(mssql_error()); if(!empty($result_record)) { while ($row_record = mssql_fetch_array($result_record)) { $id_record = $row_record['id']; } } print_r ($sql_record); in the above line you are printing out the query. I think that's not what you want... greets Zoltán Németh The result of the print_r displays only the last record that matches the query criteria. I tried a foreach instead of a while with no luck. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: posting variables to parent frame
tedd wrote: At 2:35 PM -0400 4/25/07, Al wrote: Incidentally, br/ is an error for html. Really -- why don't you tell the w3c about that? http://www.w3schools.com/tags/tag_br.asp Actually your example here is wrong. It is unfortunate how they have written this explanation. In xhtml br/br is quite correct. br/ is an acceptable short notation. For any empty element you have to write an opening and closing tag and these tags can be shortened. So p/ is perfectly valid xhtml. OR maybe tell me why my site passes w3c HTML validation: http://validator.w3.org/check?uri=http://sperling.com/examples/captcha/ If it's an error, they didn't catch it. You are quite correct here though. br/ does not seem to be considered an error by the validator. Lori -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Find MAC Address in PHP
Nathaniel Hall wrote: Davi wrote: I know it can be done because I have a Fedora Core 4 system doing it right now. I didn't have to do anything special for it to work. The system I am working on now is a Fedora Core 6 box. In /var/log/messages I receive: Apr 24 09:33:51 STUAUTH kernel: audit(1177425231.020:114): avc: denied { execute } for pid=31786 comm=httpd name=bash dev=dm-0 ino=916642 scontext=root:system_r:httpd_t:s0 tcontext=system_u:object_r:shell_exec_t:s0 tclass=file The avc: message means its SELinux, as you suspected. You need to temporary disable the firewall by setting it to permissive, then use audit2allow to find out what the settings need to be to set up the permissions properly. Look up audit2allow in the man page - they describe the process in there. Lori -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CSS vs. Tables OT
Wolf wrote: OK, so I like sticking my nose in sometimes... Accessibility Standards and being bobby approved. http://webxact2.watchfire.com/report.asp?t=2#priority3 on http://lonewolf.homelinux.net/ Is just about as good as http://www.csszengarden.com Just the same 1 error :) At least show something that looks like a table! Check out http://home.tiscali.nl/developerscorner/ontario-dwic/test-ontario-step11.htm This was a collaboration between me and a CSS expert - francky kleyneman http://home.tiscali.nl/developerscorner/index.html. Not a table to be seen and it expands if you increase or decrease the font. The final version also meets section 508 and WAI guidelines for accessibility and works on Lynx (text browser) and screen readers. Now contrast that with the Drinking Water Ontario http://www.ontario.ca/ONT/portal51/drinkingwater/kcxml/04_Sj9SPykssy0xPLMnMz0vM0Y_QjzKLd4oPMATJgFjugfqRaCIBcJEgfW99X4_83FT9AP2C3NCIckdHRQDMbRp9/delta/base64xml/L3dJdyEvd0ZNQUFzQUMvNElVRS82X0JfUDI%21?lang=en site. Link is on the right side of the above page if it doesn't come through in the previous sentence. Takes 300 sec to load, when it loads at all. Table soup! Now can we please close this thread! There are better forums to discuss this - it has nothing to do with PHP!! Lori -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SQL Source Control
Richard Davey wrote: Hi all, I know a lot of you use various means for PHP source control (CVS, SVN, etc), which is all well and fine, but how do you manage source control on your databases? Say you've got an upgrade to a site, all of the new PHP files are controlled by SVN, so you can rollback at any time, but say the upgrade includes several key modifications to a MySQL table and perhaps the changing of some core data. How (if at all?!) do you handle the versioning of the database and data itself, so you can keep both PHP and SQL structure in sync? Cheers, Rich Rich, This is a well-known problem that comes from the fact that the database is an infrastructure component rather than a source component. You would have the same issue if you were to upgrade the operating system software, for example. What most people do is use their tool of choice to create the DDL/DML update scripts and put those under source control. To version the data you need to make database backups at well-understood times and grab the data files if appropriate. Rolling back a change is a matter of recovering the database and files to a point in time along with the sources. I don't know of any management tools for this part of it. Most larger organizations have different people responsible for the database and web tiers, so a single tool won't do. Some folks are trying to use ClearCase automation to manage a lot of it, but it's still a work in progress... In a smaller environment I would be inclined to create shell/whatever scripts to do the actual implementation. If you parameterize the connection/server details you can test the implementation in a QA environment before going live - less need for rollbacks that way. The shell scripts greatly reduce the chance of finger trouble which is key if your implementation is being done at some uncivilized hour or by rookies. If you want to truly embrace the New World, you can do all of this using Ant, which has built-in tasks for CVS/SVN as well as file movement, etc. It can also run shell scripts for the database stuff. ...Lori -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UPDATE and redirect
Marcelo Wolfgang wrote: and what if $_GET['id'] is something like 1; DROP TABLE tb_emails; ?? SQL injection just waits to happen I think tha tit will be too much of a hacker effort just to kill a table of contact emails, and also he will have to guess ( is there other way ? ) the table name, but just to be on a safer side: - Is there a way to say that id can only be a number ? something like $id:Number = $_GET['id']? TIA If your id should only have digits in it, use if (! ctype_digit($_GET['id'])) { print invalid parameter error message or exit or whatever; } This doesn't work with negative integers - it really checks to make sure that there are only digits, but it is very handy for validating GET or POST variables. There are other ctype functions as well... Lori -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UPDATE and redirect
Marcelo Wolfgang wrote: and what if $_GET['id'] is something like 1; DROP TABLE tb_emails; ?? SQL injection just waits to happen Something I just thought, he could do a drop table inside an update statement ? because the query is : UPDATE tb_emails SET bol_active = $action WHERE auto_id = $id so if he changed the $action or the $id, it will be inside the UPDATE, doesn't changing any of the variables to a DROP TABLE just give an error ? TIA Marcelo No. That's why he put the semi-colon after the 1. It becomes update tb_emails set bol_active = $action where auto_id = 1; drop table tb_emails; That's two separate statements that will be happily executed if you're not careful. Try it (on a scratch table). Lori -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array remove function?
Tijnema ! wrote: On 4/10/07, Richard Lynch [EMAIL PROTECTED] wrote: http://php.net/unset That works when you know the key, but will that work when you only know the value? Tijnema Use array_search() and unset()? Lori On Tue, April 10, 2007 2:49 pm, Tijnema ! wrote: Hi, Is there currently a function that removes a key/value from an array? I use this code right now: function array_remove($array,$remove,$remove_value = true) { foreach($array as $key = $value) { if($remove_value $value != $remove) { $new_array[$key] = $value; } elseif (!$remove_value $key != $remove) { $new_array[$key] = $value; } } return $new_array; } array_remove(array(1=2,2=3),2,true); // array (2=3) array_remove(array(1=2,2=3),2,false); // array (1=2) Anyone knows if there already exists such function? Else should i create future request? Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array remove function?
Tijnema ! wrote: On 4/10/07, Daevid Vincent [EMAIL PROTECTED] wrote: OMG. Now that is the best idea. How simple. Guess I learned something new today too! :) -Original Message- From: Lori Lay [mailto:[EMAIL PROTECTED] Use array_search() and unset()? Interesting, I didn't thought of that :) But should i submit a future request for such function? Tijnema Gad. I have enough trouble keeping track of all the functions php has already :-) I wouldn't use it very often, but others might... I think I can smell a long thread starting ;-) Lori -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql if empty
Richard Lynch wrote: I am amazed by the sheer number of just plain WRONG answers to this one... Were they all from April 1 or something?... Yes it's unfortunate. I think part of the problem was that several people, including myself, weren't entirely clear on what he was after. When I re-read his note later, I realized that the num. rows test was the correct answer. When you're posting to the list, you have to remember that we're not sitting beside you! Try to tell us what you hope to accomplish with your script and you might get better replies... Lori -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Retrieving parameters passed from .html...?
Anthony J. Maske wrote: See... the second I sent this I took a sip of red-bull and my brain cleared up... $topicID = $_GET['showtopic']; Right? Yes. And if you have a form that uses the POST method, it would be $_POST['element']. Some of the other variables you will eventually need: http://ca3.php.net/manual/en/reserved.variables.php Lori Anthony J. Maske [EMAIL PROTECTED] http://home.comcast.net/~ajmaske -Original Message- From: Anthony J. Maske [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 10, 2007 8:33 PM To: PHP General Subject: [PHP] Retrieving parameters passed from .html...? Hey all, My first post here..., new to php and so far doing great picking it up... but, tonight I'm having a brain fart... How do you pick up (read) the parameters passed into a php script from an html file? Given... http://somewhere/dosomething.php?showtopic=9 How do you read or get the value showtopic and the value of 9? I know this is simple but I'm pulling my hair out here... Thanks! Anthony -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Evaluating strings...
Anthony J. Maske wrote: Hey, Thanks for the quick response on Retrieving parameters... This is another that has me stumped... if (trim($Line) = 'body') { $InBody = true; } elseif (trim($Line) = '/body') { $InBody = false; } $Line is a line from a html file, I'm trying to parse through it to ignore everything but the body section. When I run the above I get the following... Fatal error: Can't use function return value in write context in C:\wwwRoot\anthony.maske\cfr.php on line 43 If I do this... $Tag = trim($Line); if ($Tag = 'body') { This assigns 'body' to $Tag - see below. $InBody = true; } elseif ($Tag = '/body') { $InBody = false; } Why won't the later work? What am I missing in the first snip... Thanks again...! Anthony Another page for you to read: http://ca3.php.net/manual/en/language.operators.comparison.php You're confusing assignment and comparison. = is for assignment, you have to use == or === for comparison. Lori -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need a working SOAP example using SOAP -- PHP is blocking the calls
Daevid Vincent wrote: c, could you be having a problem related to the allow_url_fopen ini setting? Now we're talkin! Okay, I made sure that allow_url_fopen and allow_url_include are both on. Verified via phpinfo(); Still no luck. :-\ However, this sparked an idea... I have been using my WinXP and IE to hit my Gentoo notebook running apache2/php/etc. (samba mounting the /home/machine/... to edit the files) When I fired up KDE and hit the EXACT same pages (which are now local), they magically worked! So now the question is, what setting do I have to change in my php.ini file to get remote requests to work? I'm not following what you mean by local and remote and when your considering something to be one or the other. (locutus) Gentoo/Notebook/Apache/PHP/Samba (gabriel) WinXP/IDE/IE6 All the code sits on locutus. I samba share the directory so can edit in my HomeSite IDE on gabriel. I edit my 'hosts' file (on both machines) to point at the proper IP (172.16.35.223 machine.locutus.com) setting up a vhost on locutus, etc... I can make the initial connection to client.php. I can do most anything (php, mysql, htaccess, etc), as locutus is a webserver -- I use this method to develop a dozen sites, all work flawlessley. You follow so far? This should be a pretty normal setup. Nothing fancy here. So, as stated in previous post. If I use gabriel to access http://machine.locutus.com, I can get to any of the individual pages related to this SOAP exercise (server.php, .wsdl, client.php, etc.). The problem is that the client.php can't make a server.php call though, and throws that exception. Now, to add to my confusion and simultaneiously lets me know that my actual CODE is working, as per the spark above, I fired up KDE on locutus. Then I hit the exact same URL, and pinch my ass and call me Charlie, the SOAP example works. SAME EXACT CODE. SAME EXACT FILES. SAME EXACT URLS. Something in PHP land (php.ini) seems to be horking me. I had a co-worker put my code on his linux (debian) box, and he could then connect from his XP to the URL and it worked for him too (even using https://). You might be thinking, well just diff the php.ini files and see. Not so easy my friend. They're not condusive to that. And we tried to eyeball what we could, but didn't see anything obvious. I thought for sure allow_url_fopen and allow_url_include were my silver bullets here, but they're 'On' in both php.ini files (his and mine). windows firewall springs to mind but I can't tell if it could even be involved from your current description. Windows Firewall should not be an issue here b/c the soap requests are originating from locutus to locutus -- the files are in the same directory. SOAP (at this stage) is only an exercise -- it's not making any remote calls across a network. Daevid, I am by no means an expert on this, but I know that when we've had issues with running some scripts, we had to look into the Linux security settings. We're running SE Linux (Red Hat) and that shuts down a lot of the remote access. When we were trying to get some CURL scripts working, we had to temporarily disable the Linux firewall so that we could track the calls in the messages log. Then we could see what the required privileges were and set things up appropriately. I don't know if Gentoo has anything like that or if you have any of the security stuff turned on, but you might want to check the equivalent of the messages log in Gentoo and see if that's where you're being blocked. Lori -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql if empty
[EMAIL PROTECTED] wrote: If I search for something in mysql that returns an empty result I cant get it to return No result found always returns Found even though the recoed does not exist... $sql = SELECT Client FROM booked WHERE Name = 'larry'; $result = mysql_query($sql); if ($result == ) { echo No result found; } echo Found; Use isset. if (!isset($result)) { echo No result found; }... Lori -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] foreach question
[EMAIL PROTECTED] wrote: both examples do the same thing.. no, ex1 only has 1 br / so outputs like.. item1item2item3item4item5br / Where as I want this.. item1br / item2br / item3br / item4br / item5br / ie a line break after every item. Silly question, perhaps, but are you sure $_POST is an array (with 5 elements)? What you have written should produce a break after each item if POST is a 5 element array. However if POST is a single element with the five items concatenated together, then they would be printed the way you have it listed above... It might be better to post the full script to the list. Lori - Original Message - From: Sebe [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: Monday, April 09, 2007 1:22 AM Subject: Re: [PHP] foreach question [EMAIL PROTECTED] wrote: I have .. foreach( $_POST as $key ) {echo $keybr /; } and that gives me item1 item2 item3 item4 item5br / how do I write it to give me item1br / item2br / item3br / item4br / item5br / Thanks both examples do the same thing.. -- 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] foreach question
[EMAIL PROTECTED] wrote: Sorry this is the full script... whois.php html bodyspan style=font-size:13;font-family:Arial,Verdana; form method='POST' action='whois.php' pbEnter Domain Names (one per line)/b/p textarea name='domain' cols=50 rows=8 style=font-size:13;font-family:Arial,Verdana;/textareap Gotcha! A textarea does not produce an array. Even though the user should be separating the lines with a line break, this turns into one long string with line breaks in it, not separate array elements. You will have to do this manually. Actually, you could probably use nl2br to insert BR's before the line breaks (it doesn't replace them, but that's usually good enough). Lori input type='submit' value=Submit Domain Query /form pbuWhois Results:/u/b/p ?php foreach( $_POST as $key ) { echo $keybr; } ? /body /html - Original Message - From: Lori Lay [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: Monday, April 09, 2007 5:20 AM Subject: Re: [PHP] foreach question [EMAIL PROTECTED] wrote: both examples do the same thing.. no, ex1 only has 1 br / so outputs like.. item1item2item3item4item5br / Where as I want this.. item1br / item2br / item3br / item4br / item5br / ie a line break after every item. Silly question, perhaps, but are you sure $_POST is an array (with 5 elements)? What you have written should produce a break after each item if POST is a 5 element array. However if POST is a single element with the five items concatenated together, then they would be printed the way you have it listed above... It might be better to post the full script to the list. Lori - Original Message - From: Sebe [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: Monday, April 09, 2007 1:22 AM Subject: Re: [PHP] foreach question [EMAIL PROTECTED] wrote: I have .. foreach( $_POST as $key ) {echo $keybr /; } and that gives me item1 item2 item3 item4 item5br / how do I write it to give me item1br / item2br / item3br / item4br / item5br / Thanks both examples do the same thing.. -- 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] Question about form submitting
Tijnema ! wrote: On 4/3/07, Mário Gamito [EMAIL PROTECTED] wrote: Hi, Sorry for the lame question, but i didn't find a satisfactory answer in the web. I have this subscribe form (subscribe.php) and on submit i have to check for errors: a) password and password confirmation mismatch; b) missing filled fields c) check e-mail validity d) etc. My question is how do i make all these possibilities show a different error message without leaving subscribe.php ? I know that the for action must be subscribe.php, from there i'm blind as a bat. Any help would be appreciated. Warm Regards -- :wq! Mário Gamito This can only be done with Javascript if you don't want to leave the page. And so, you're on the wrong list, search for a javascript list :) Tijnema Actually, that's not quite true. It's usually easier in Javascript, but if you want to do a pure PHP method, read on. This does require that you use the POST method for your form, but that's usually preferred anyway. ?php if ($_SERVER['REQUEST_METHOD'] == 'GET') { ? form action=?php echo $_SERVER['SCRIPT_NAME'] ? method=post // Regular form contents go here /form ?php } else { // Insert form processing code here - including field validation } ? This uses the PHP SCRIPT_NAME server variable for the form name so that you don't have to worry about the script location and you can move it if necessary without having to change the script. I copied this from PHP Cookbook by O'Reilly. It's not a bad book, if you can get it where you are... Lori -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about form submitting / clarification
Mário Gamito wrote: Hi, Of the three items you specify a and b should be handled with Javascript in an onsubmit handler. The error messages would be generated by this handler. Email validity would have to be handled by the web server and your php script, usually by trying the address. I think i was misunderstood. I know how to do the error handling. What i don't know is how to display the error messages in the same page as the submit form. Warm Regards To expand on my previous response: create a function that displays the form and takes an errors array as an argument. The function would display the form with print commands that would display the error messages. If there are no errors, then just the form is displayed, but if there are errors they are printed right next to the form element. For example: in display form function: $defaults['name'] = isset($_POST['name']) ? htmlentities($_POST['name']) : ' '; tdYour Name:/td td?php print_error('name', $errors) ? input type='text' name='name' value='?php echo $defaults['name'] ?' //td You will also need a print error function that takes the input element name and errors array as arguments. The $defaults variable is set to blank if the form is being displayed for the first time or the value input by the user if the form is being redisplayed after validation by using the POST variables. Lastly you will need a form validation function that would populate the errors array. This would be an associative array with the form field names as keys and the error messages as values. The entire code is available in the book I mentioned previously. I can't replicate it here due to the obvious copyright issues, although the example code is available on O'Reilly's site (http://www.oreilly.com/) Search for PHP Cookbook and select the second edition. This is all very difficult to explain in an email, but hopefully I've given you enough to chew on, as it were... Lori -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php