|
Alright this should be the last question I have with regards to this particular project. I've got everything working as it should and I'm trying to make a report button. That is to say you click the button and it sets the field REPORT to 1 instead of 0 (default) in the sql and I can go from there on fixing it. I've been working with forms so I know how to make a form and how to change the value in the sql but is there any way for me to make just a single button that executes the php code with no user input beyond the action of clicking the button? It would be preferable for this to be done without any sort of page reloading or anything to make it as painless as possible to flag a video as reported.
|
# ? Aug 26, 2008 04:57 |
|
|
# ? May 21, 2024 17:32 |
|
The March Hare posted:I've been working with forms so I know how to make a form and how to change the value in the sql but is there any way for me to make just a single button that executes the php code with no user input beyond the action of clicking the button? Probably with hidden fields: code:
|
# ? Aug 26, 2008 05:15 |
|
Oh - thanks. I didn't know that existed. I'll give it a go in the morning and report back with results.
|
# ? Aug 26, 2008 05:23 |
|
The submit button is its own field. Can look for $_POST['submit'] == 'Report' and skip the hidden variables.
|
# ? Aug 26, 2008 05:32 |
|
Mine GO BOOM posted:The submit button is its own field. Can look for $_POST['submit'] == 'Report' and skip the hidden variables. Yeah, I only wrote it the way I did because I prefer to explicitly check to see if $_POST["submit"] has been sent before checking the rest of the form. Whatever works, though.
|
# ? Aug 26, 2008 06:35 |
|
Mine GO BOOM posted:The submit button is its own field. Can look for $_POST['submit'] == 'Report' and skip the hidden variables. Internet Explorer doesn't send the value of the submit button if the user submitted the form without clicking it, e.g. by pressing enter in a text field, so sometimes it can be useful to identify the action in a hidden value.
|
# ? Aug 26, 2008 10:26 |
|
DaTroof posted:Internet Explorer doesn't send the value of the submit button if the user submitted the form without clicking it, e.g. by pressing enter in a text field, so sometimes it can be useful to identify the action in a hidden value. Holy poo poo I have been wondering why a submit button is posted sometimes and not others for probably over a year now, I just haven't been bothered enough to look into it. Thanks!
|
# ? Aug 26, 2008 15:11 |
|
Alright, while that does work like a charm I would really like to be able to execute this code (a simple sql entry) without any sort of a page load/reload on the user end. Is this a pipe dream or is this possible?
|
# ? Aug 26, 2008 19:01 |
|
You'd have to rig up an Ajax request to process the form without reloading the page, but that ain't hard at all (especially if you're using something like jQuery in your project.)
|
# ? Aug 26, 2008 19:06 |
|
Alright I'll look into ajax. I'm not using jQuery (don't even know what it is) but now that I know this is not something PHP can do I guess I'll go read about Ajax e; looked up jQuery, guess I'll give this a go. Thanks a bundle! The March Hare fucked around with this message at 19:10 on Aug 26, 2008 |
# ? Aug 26, 2008 19:08 |
|
I'm trying to create a page where my students can enter in answers, and it will email their answers as a txt file to me so I can grade it. I've got it so I can save their answers as a file specific to their name (e.g. "BethHarrison.txt"). However, I'd like to have that file sent to me by email. Any idea how to do this?
|
# ? Aug 26, 2008 21:43 |
|
moana posted:I'm trying to create a page where my students can enter in answers, and it will email their answers as a txt file to me so I can grade it. Did you try searching the documentation?
|
# ? Aug 26, 2008 22:04 |
|
duz posted:Did you try searching the documentation?
|
# ? Aug 26, 2008 22:43 |
|
The easiest thing is probably just read in the file and send it inline.
|
# ? Aug 26, 2008 22:44 |
|
duz posted:The easiest thing is probably just read in the file and send it inline.
|
# ? Aug 26, 2008 23:06 |
|
I'm currently working on a site using a free PHP shopping cart that utilizes session variables to track the items/cart. http://www.freebert.com/Products/FreePHPShoppingCart/ is the cart I'm currently using. My question is how can I send the contents of the cart via email to my business email? I currently have a PHP Email form setup but I'm not sure how to pass the cart contents to the variable. in summary I would like to have a "send order" button where it will email the cart contents of their session to my business email.
|
# ? Aug 27, 2008 03:48 |
|
HewlettZ posted:I'm currently working on a site using a free PHP shopping cart that utilizes session variables to track the items/cart. Well, I went to the site to try and get a feel for it, see what kind of documentation there is and whatnot, and I must say that looks absolutely atrocious. Have you heard of Zen Cart? It's totally free with a huge community to support it and a website that doesn't look like it belongs on GeoCities. You can email orders with it quite easily too. However, if you really want to stick with that. It would just be a matter of parsing the session data and then php:<? mail($my_business_email, $subject, $mail_body, $header); ?>
|
# ? Aug 27, 2008 07:27 |
|
I have looked at Zen Cart I think the problem with that is I already have a site created in html/php and ZenCart seems to be a standalone package with their own templates. I couldn't really find a good php shopping cart package that integrates into an already functioning site.
|
# ? Aug 27, 2008 08:46 |
|
I'm having tons of issues with CakePHP. It seems like if you ever venture out of the realms that tutorials and the inadequate manual covers, it has a 'right' way to do things, but good luck finding the 'right way' that fits what you're trying to accomplish, and trying to figure out that 'right way' involves a ton of source diving and refactoring of code you've already written to something 'acceptable' that you hope to god you can fix later on down the line. I find myself blindly following tutorials almost to the letter, and trying to do something 'clever' or apply anything I've learned in a Cake tutorial or manual to something else always seems to get me in trouble. Are there frameworks out there that allow a little more flexibility, or is this sort of thing indicative of all of the frameworks out there? Unboxing Day fucked around with this message at 15:41 on Aug 29, 2008 |
# ? Aug 29, 2008 15:38 |
|
Emo Businessman posted:Are there frameworks out there that allow a little more flexibility, or is this sort of thing indicative of all of the frameworks out there? CodeIgniter is awesome AND very flexible. SA thread: http://forums.somethingawful.com/showthread.php?threadid=2758594
|
# ? Aug 29, 2008 15:43 |
|
Emo Businessman posted:I'm having tons of issues with CakePHP. It seems like if you ever venture out of the realms that tutorials and the inadequate manual covers, it has a 'right' way to do things, but good luck finding the 'right way' that fits what you're trying to accomplish, and trying to figure out that 'right way' involves a ton of source diving and refactoring of code you've already written to something 'acceptable' that you hope to god you can fix later on down the line. I find myself blindly following tutorials almost to the letter, and trying to do something 'clever' or apply anything I've learned in a Cake tutorial or manual to something else always seems to get me in trouble. I think the Zend Framework (http://framework.zend.com/) is all kinds of awesome.
|
# ? Aug 29, 2008 16:42 |
|
Emo Businessman posted:I'm having tons of issues with CakePHP. It seems like if you ever venture out of the realms that tutorials and the inadequate manual covers, it has a 'right' way to do things, but good luck finding the 'right way' that fits what you're trying to accomplish, and trying to figure out that 'right way' involves a ton of source diving and refactoring of code you've already written to something 'acceptable' that you hope to god you can fix later on down the line. I find myself blindly following tutorials almost to the letter, and trying to do something 'clever' or apply anything I've learned in a Cake tutorial or manual to something else always seems to get me in trouble.
|
# ? Aug 29, 2008 17:39 |
|
I'm trying to hash some stuff using the Adler32 algorithm, but my results are not coming out right:php:<? /* How the client does it (in Javraaagh!) java.util.zip.Adler32 checksum = new java.util.zip.Adler32(); checksum.update((String)(user_id + timestamp + key).getBytes()); return checksum.getValue(); */ $sharedKey = 'Hah! No.'; $userNumber = '13574725'; $timeStamp = '29501416062008'; $hashContext = hash_init('adler32'); hash_update($hashContext, $userNumber); hash_update($hashContext, $timeStamp); hash_update($hashContext, $sharedKey); //result is the same if I concat the the data and call hash_update once //and/or if I call hash('adler32',$catData) $result = hexdec(hash_final($hashContext)); ?> Our $result is not matching what the Java equivalent (in the comment) is coming up with, and, just in case you feel like telling me it's Java's fault, Python's zip.alder32() method gives me the same answer as the Java method, so I'm 99% certain that either I'm doing something wrong or PHP is hosed up somehow. Since PHP is fairly widely used, I would assume someone would have found this problem before me and fixed it, so I can only conclude that I'm doing something wrong. Question is: what? Munkeymon fucked around with this message at 21:46 on Aug 29, 2008 |
# ? Aug 29, 2008 20:10 |
|
Emo Businessman posted:I'm having tons of issues with CakePHP. It seems like if you ever venture out of the realms that tutorials and the inadequate manual covers, it has a 'right' way to do things, but good luck finding the 'right way' that fits what you're trying to accomplish, and trying to figure out that 'right way' involves a ton of source diving and refactoring of code you've already written to something 'acceptable' that you hope to god you can fix later on down the line. I find myself blindly following tutorials almost to the letter, and trying to do something 'clever' or apply anything I've learned in a Cake tutorial or manual to something else always seems to get me in trouble. I've built probably 20+ sites in CakePHP. I used to get frustrated as hell with it all the time as a lot of the older tutorials put you in a sort of tunnel vision with how it's supposed to work. It also doesn't help that even comparing the 1.2 version from a year ago to now, you're faced with huge differences in how you're expected to do things. I'd say just ignore the tutorials except for the "getting started" ones, and for any stumbling block to run into along the way, search their google group and sort by date (very important since the difference in code I mentioned). It gets a lot of flak for the "conventions" it asks you to adhere to, but there's almost nothing that's not overridable...you just have to know where it is, and that's half the problem. But I can say that a complex set of tables set up for Cake with the appropriate relationships defined is a thing of beauty when you start querying that data. I don't think I could handle 3NF without going insane if it wasn't for their model structure. Just out of curiosity, what's one of the things you had to struggle with? edit: if I had to start all over learning a PHP framework given the knowledge I have today, I'd 100% say to go with Zend framework. Leavy fucked around with this message at 21:43 on Aug 29, 2008 |
# ? Aug 29, 2008 21:35 |
|
{long post about why my include() was broken} I fixed it but thank you. Safety Shaun fucked around with this message at 03:32 on Aug 30, 2008 |
# ? Aug 30, 2008 03:01 |
|
My PHP is really rusty and I ran into this problem when building a site for something I'm making. I have an associative array with strings as the keys and they point to arrays:php:<? $contents = array ( 'introduction' => array( ... , 'starting-out' => array( ... , 'types-and-typeclasses' => array( ... , 'syntax-in-functions' => array( ... , 'higher-order-functions' => array ( ... , ... ) ?>
|
# ? Aug 30, 2008 12:25 |
|
electric_vaseline posted:However, if you really want to stick with that. It would just be a matter of parsing the session data and then Escaping the data too - although unlikely, there is the possibility of header injection in php if the adress or subject can be controlled by the user.
|
# ? Aug 30, 2008 12:40 |
|
Bonus posted:My PHP is really rusty and I ran into this problem when building a site for something I'm making. I have an associative array with strings as the keys and they point to arrays: php:<? #based on the array you described function getPrevNext($dict, $current_key) { $keys = array_keys($dict); $num_key = array_search($current_key, $keys); return array('prev'=>$keys[$num_key-1], 'next'=>$keys[$num_key+1]); } print_r(getPrevNext($contents,'types-and-typeclasses')); ?> code:
edit: fixed poo poo. didn't test properly and if there was no key corresponding, would return the firt one as next. This one will throw an exception if the key doesn't exist: php:<? function getPrevNext($dict, $current_key) { try { $keys = array_keys($dict); $num_key = array_search($current_key, $keys); if($num_key===False) throw new Exception ("key '{$current_key}' not in array"); return array('prev'=>$keys[$num_key-1], 'next'=>$keys[$num_key+1]); } catch(Exception $e) { echo $e; } } ?> MononcQc fucked around with this message at 16:07 on Aug 30, 2008 |
# ? Aug 30, 2008 15:40 |
|
Ah, awesome! Yeah, that looks much more elegant! My PHP's real rusty, I totally forgot about array_keys and array_search. Thanks!
|
# ? Aug 30, 2008 15:42 |
|
So I'm teaching myself PHP for a specific project involving copying .flv files from one site and rehosting at another (EA Sports World videos to get around their 5 video limit specifically), and I've run into a wall at getting the videos to transfer directly from their server to mine. I've tried using get_stream_contents and couldn't get that to work, and now I'm trying cURL, and can't get that to work. Any thoughts? Here's what I've got right now that isn't working: php:<? $ch = curl_init(); $save = fopen("videos/test.flv", "r+"); curl_setopt($ch, CURLOPT_URL, "$URL"); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); curl_setopt($ch, CURLOPT_FILE, $save); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_exec($ch); curl_close($ch); fclose($save); ?> Also, I've just got it as test.flv for now, but I'd like to save it as the same actual filename, which in this case is something like: http://videocdn.easw.easports.com/easportsworld/media2/ncaa09/526101/882A0001_4_FLV_VIDEO_iOk.flv and I'd like to save it as videos/882A0001_4_FLV_VIDEO_iOk.flv; how would I do this? Sorry if these questions come off as too newbieish, but well, I am, and I've scoured google. Thanks.
|
# ? Sep 1, 2008 07:45 |
|
kalicki posted:So I'm teaching myself PHP for a specific project involving copying .flv files from one site and rehosting at another (EA Sports World videos to get around their 5 video limit specifically), and I've run into a wall at getting the videos to transfer directly from their server to mine. For the filename, just use your favourite method of pulling the filename out of the url. There's a function for that or something. There's a function for everything. I used this: http://ca3.php.net/manual/en/function.basename.php I would probably separate the url functions and the writing functions instead of interspersing them, too. php:<? $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "$URL"); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); curl_setopt($ch, CURLOPT_FILE, $save); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($ch); curl_close($ch); basename($URL); $save = fopen("videos/$filename", "r+"); fwrite($save,$data); fclose($save); ?>
|
# ? Sep 1, 2008 08:12 |
|
Thanks, I've gotten it working... kind of. It now saves this :V code:
Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in public_html/ea/upload.php on line 26 Then, dropping the redirected url into my function works, so at least that part is filled. I guess I'll try messing about with the couple functions that deal with this error in the help here unless anyone has a better suggestion: http://ca3.php.net/manual/en/function.curl-setopt.php Thanks! edit: Nevermind, got this part working. Made it so it downloads the 302 page, eregi through it for the link, and then redo another cURL with it. kalicki fucked around with this message at 22:58 on Sep 1, 2008 |
# ? Sep 1, 2008 08:51 |
|
I'm trying to use preg_replace to perform word censor with PHP but it seems my regexp doesn't work as exprected. At first I was using str_replace, but they are too easily evaded, instead of "gently caress" just type "fuuck" and it gets displayed and not filtered. This is my code: php:<? $Msg = 'gently caress !'; echo 'Before: '.$Msg.'<br><br>'; $Censor[] = '{f*u*c*k*}'; $Msg = preg_replace($Censor, '*static*', $Msg); echo 'After: '.$Msg.'<br><br>'; ?> This is the result: code:
What am I doing wrong ? EDIT: Got it, had to use a + instead of a *, since * matches 0 or more, and + matches 1 or more. Alex007 fucked around with this message at 03:03 on Sep 3, 2008 |
# ? Sep 3, 2008 01:43 |
|
That is a pretty horrible way of filtering because it will match on anything that contains f, u, c, and k in that order, whether it be a word or a paragraph. Edit: Actually it isn't but the you have people putting in underscores or spaces and the whole filtering falls apart again. waffle iron fucked around with this message at 05:11 on Sep 3, 2008 |
# ? Sep 3, 2008 05:09 |
|
waffle iron posted:That is a pretty horrible way of filtering because it will match on anything that contains f, u, c, and k in that order, whether it be a word or a paragraph. Yeah that's the next step now that I have my regexps under control. Here's a regexp that catches a lot more code:
But drat, it's almost unreadable. Now I remember why I used to hate regexp Alex007 fucked around with this message at 11:50 on Sep 3, 2008 |
# ? Sep 3, 2008 11:36 |
|
Alex007 posted:Yeah that's the next step now that I have my regexps under control. Regex Buddy It's the only piece of "development" software I've bought with my own money because it's such of a wonderful piece of program.
|
# ? Sep 3, 2008 19:36 |
|
Leavy posted:Regex Buddy A bit off topic, but there is also Regex Coach - which is free. I don't know how it compares to Regex Buddy, but it is a solid helper for testing out expressions quickly.
|
# ? Sep 3, 2008 21:58 |
|
SOLVED: Just made the array push from inside the class. So I have this class: php:<? class Course { // This class is used for generic classes (such as those with no pre-reqs) public $className; public $classDept; function getDept($connection) { $query = "SELECT `Name` FROM `dept` WHERE ID = $this->classDept;"; $deptResult = mysql_query( $query, $connection ) or die( mysql_error() ); if (!mysql_num_rows($deptResult)) die(); while($row = mysql_fetch_array($deptResult, MYSQL_ASSOC)) { return $row['Name']; } } } class ComplexCourse extends Course { // Tack on some vars for more complex courses // What classes MUST be taken prior? public $preReq = array(); // What classes MUST be taken parallel? public $coReq = array(); // What classes invalidate this class? public $notReq = array(); } ?> php:<? array_push($courses[$classesRow['ID']]->preReq,$reqRow['Requires']); ?> ijustam fucked around with this message at 23:31 on Sep 6, 2008 |
# ? Sep 6, 2008 17:53 |
|
I am trying to create a PHP applet that will monitor IIS log files (using the tail command) for a specific event and perform an action when that event is found. I know how to parse a log file when it is written to disk, but how do I do this in such a way that the real time log stream is monitored?
|
# ? Sep 8, 2008 19:03 |
|
|
# ? May 21, 2024 17:32 |
|
Agrikk posted:I am trying to create a PHP applet that will monitor IIS log files (using the tail command) for a specific event and perform an action when that event is found. I guess you could do this: php:<? $pipe = popen('tail -opt /path/to/logfile','r'); while(!feof($pipe)) { //print stuff here } fclose($pipe); ?>
|
# ? Sep 8, 2008 20:58 |