|
eHacked posted:That seems way too simple. It's about that simple. I'd add a few more headers to make sure IE doesn't choke on it, among other things: php:<? header('Pragma: public'); header('Cache-Control: max-age=0'); header('Content-Type: text/plain'); header('Content-Length: ' . strlen($fl)); header('Content-Disposition: attachment; filename="export.txt"'); echo $fl; exit; ?>
|
# ? Mar 12, 2009 18:20 |
|
|
# ? May 15, 2024 08:00 |
|
Eararaldor posted:Funny you should mention that. I was actually checking it out but was a little miffed as to how I actually implement it. Download jquery.ui from http://jqueryui.com/download The following code will build up on the previous "tutorial" I posted a few days ago. (So if you want the form to submit to a database use that code, this is merely demonstrating the date picker being submitted to a form and response via ajax.) Instead of spamming the board, I've posted a code example: http://littlesparrows.com/sa/datepicker/ - view source to see what's going on. I've rared it for you here so you can download the source: http://littlesparrows.com/sa/datepicker.rar Hope it helps wil fucked around with this message at 19:03 on Mar 12, 2009 |
# ? Mar 12, 2009 18:59 |
|
wil posted:Download jquery.ui from http://jqueryui.com/download Very much so! I reall apreciate the help, however I have one more question left to ask. How would I go about converting 00/00/00 to sql datetime? I guess I could cheat and swap the output to a varchar instead, but would be interested to hear how the proffesionals do it.
|
# ? Mar 12, 2009 21:33 |
|
It can be formatted using the formatDate parameter on the javascript side, but it might be faster to do it on the server side in the processForm.php file. Change your processForm.php to reflect this: code:
It's a hack, but it works. Your time will always be 00:00:00 because it's never going to be set from the calendar. wil fucked around with this message at 20:04 on Mar 13, 2009 |
# ? Mar 12, 2009 22:20 |
|
[stuff about sqlite performance] Edit. Nevermind. http://www.sqlite.org/speed.html suggests using BEGIN; and COMMIT; blocks, and those are working. Fangs404 fucked around with this message at 02:36 on Mar 13, 2009 |
# ? Mar 13, 2009 02:28 |
|
As part of a work project I've been asked to port some basic Django/Rails type functionality into the inhouse CMS. Oh boy. Unfortunately my prefered option of "welp, lets use django" probably wont go down well considering the company is convinced this godawful sluggish php cms it owns is worth millions in IP blah blah Anyway, I've written a url router, with the following code;- php:<? class router { function router() { $this->table = array(); $this->references = array(); } function addroute ($route,$obj,$funct) { $this->table[$route] = array($obj,$funct); } function route() { foreach ($this->table as $k=>$v) { $urlsplit = explode(URL_SLICE,$_SERVER['REQUEST_URI']); $url = $urlsplit[1]; if (preg_match_all($k,$url,$matches)) { global $_URL; $_URL = $matches; $obj = new $v[0](); print $obj->$v[1]($_SESSION,$_REQUEST,$_URL); } } } } ?> The questions is, how does one write a regex that preg_match_all can read so that a url like /users/32 can match on /users/ and then extract the 32 into a variable. I know in perl and python you can use named capture groups to do this , but I honestly have no loving idea how to do it in any of these, let alone php. Any regex gurus able to help me here?
|
# ? Mar 14, 2009 07:41 |
|
duck monster posted:The questions is, how does one write a regex that preg_match_all can read so that a url like Not a guru, but something like this: php:<? function route() { foreach ($this->table as $k=>$v) { $urlsplit = explode(URL_SLICE,$_SERVER['REQUEST_URI']); $url = $urlsplit[1]; if (preg_match('!^/'.$k.'/(.*)$!',$url,$matches)) { global $_URL; $_URL = $matches[1]; $obj = new $v[0](); print $obj->$v[1]($_SESSION,$_REQUEST,$_URL); } } } } ?>
|
# ? Mar 14, 2009 08:09 |
|
FeloniousDrunk posted:Not a guru, but something like this: Well yeah, obviously, the question I was asking is how to craft the regex.
|
# ? Mar 14, 2009 08:27 |
|
Hi guys I was just wondering if a line of php code will work with a page of javascript. Because for my code I'm using this line to only allow people logged in to view the page. <?php session_start(); require_once('db.php'); include('functions.php'); checkLogin('1 2'); ?> But I'm also using javascript which I learnt from Will to provide a calendar to the form. If I add that php code to the top I get: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/grads/public_html/computing_project/login2/booking.php:1) in /home/grads/public_html/computing_project/login2/booking.php on line 1
|
# ? Mar 14, 2009 16:54 |
|
Eararaldor posted:Hi guys session_start() has to be the first thing you do, you can't be outputting anything before it.
|
# ? Mar 14, 2009 17:27 |
|
duz posted:session_start() has to be the first thing you do, you can't be outputting anything before it. It's line 1?
|
# ? Mar 14, 2009 17:33 |
|
Set the session stuff up in the main file, (the one that is calling the ajax functions) not on the formProcess.php file and you should be cool.
|
# ? Mar 14, 2009 18:58 |
|
wil posted:Set the session stuff up in the main file, (the one that is calling the ajax functions) not on the formProcess.php file and you should be cool. Yeah it was in the main page. Which was what I coudn't understand. Anyway I remade the page and now it works... Maybe my line 1 code was slightly wrong? Anyway doesn't matter. *Edit one last query for you guys I'm currently trying to make a form that updates rows on a table. Currently my form has no issues displaying the text to be edited, in their respective text boxes however I can't make the changes seem to stick. php:<? if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit") { if (!isset($_POST["submit"])) { $bookingID = $_GET["bookingID"]; $sql = "SELECT * FROM booking WHERE bookingID=$bookingID"; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); ?> <form action="edit.php" method="post"> <input type=hidden name="bookingID" value="<?php echo $myrow["bookingID"] ?>"> Room Name:<INPUT TYPE="TEXT" NAME="roomName" VALUE="<?php echo $myrow["roomName"] ?>" SIZE=30><br> <input type="hidden" name="cmd" value="edit"> <input type="submit" name="submit" value="submit"> </form> <? } ?> <? if ($_POST["submit"]) { $roomName = $_POST["roomName"]; $sql = "UPDATE booking SET roomName='$roomName' WHERE bookingID=$bookingID"; $result = mysql_query($sql); echo "Thank you! Information updated."; } } ?> Eararaldor fucked around with this message at 01:12 on Mar 15, 2009 |
# ? Mar 14, 2009 19:09 |
|
Big gotcha. Check for spaces, enters and cruft before the first <? Thats often a big cause of 'headers already sent' type errors.
|
# ? Mar 15, 2009 05:17 |
|
Hmm. Maybe my regex question needs a thread
|
# ? Mar 15, 2009 05:18 |
|
duck monster posted:Hmm. Maybe my regex question needs a thread This subforum has regexes coverered too. Post here and somebody should be able to help.
|
# ? Mar 15, 2009 08:31 |
|
Eararaldor posted:
Heh, looks like it was having an issue trying to find the id row. Fixed that by adding a: <INPUT TYPE="HIDDEN" NAME="bookingID" VALUE="<?php echo $myrow["bookingID"] ?>" SIZE=8> Working all fine now.
|
# ? Mar 15, 2009 17:31 |
|
Eararaldor posted:Just in case anyones wondering, this is now fixed. Three quick tips, you can can remove the SIZE attribute (since the field is hidden anyway), you can use a different php <?= ?> tag when you want to echo stuff, and you can close your input tag: code:
|
# ? Mar 15, 2009 17:48 |
|
Alex007 posted:Three quick tips, you can can remove the SIZE attribute (since the field is hidden anyway), you can use a different php <?= ?> tag when you want to echo stuff, and you can close your input tag: Cheers for the tips
|
# ? Mar 15, 2009 19:50 |
|
Alex007 posted:....you can use a different php <?= ?> tag when you want to echo stuff... Yeah this is true, but be sure you have short_open_tag = on set in your php.ini, otherwise it won't interpret the tags
|
# ? Mar 16, 2009 05:22 |
|
Are static variables only "static" for a particular end user's session, or are they static across all sessions for all users who visit your site (or use your PHP program for that matter)?
|
# ? Mar 16, 2009 21:57 |
|
cannibustacap posted:Are static variables only "static" for a particular end user's session, or are they static across all sessions for all users who visit your site (or use your PHP program for that matter)?
|
# ? Mar 16, 2009 22:02 |
|
FeloniousDrunk posted:It was a neverending pain in the rear end for me in that situation. Generally I'd use Word's Export to HTML (different from "Save as HTML"), then HTML Tidy, then manually fix whatever goofiness remained, then grab the body of the page and throw it into the CMS. There's also "antiword" for Linux which extracts text from Word docs (I don't think anything post-Word 97), but it also strips formatting so you'd have to reapply it all over again. Thought there might not be a really easy way. Is the act of tags in a database fine then? thats the first thing I thought of but thought "I bet thats a big no no".
|
# ? Mar 17, 2009 11:17 |
|
Vedder, FCKEditor has a built in "Paste from word" button that will strip all over the crap out and use standard html (well.. not really standard, but good enough I guess) to format it versus the Word formatting.
|
# ? Mar 17, 2009 15:41 |
|
Question: Have any of you used any affordable shopping cart systems that are not opensource (Zen Cart, osCommerce)? If so, which would you recommend?
|
# ? Mar 17, 2009 22:46 |
|
KarmaticStylee posted:Question: Have any of you used any affordable shopping cart systems that are not opensource (Zen Cart, osCommerce)? If so, which would you recommend? Zorilla fucked around with this message at 23:48 on Mar 17, 2009 |
# ? Mar 17, 2009 23:45 |
|
Ok one more stupid question: I have many URLs that I want to forward to new, prettier URLs. They look like this: http://sitename.com/Site_Name-Number-Type-Article_Name/?webmaster_id=xxxx&track=TRACK With htaccess I can pull out the "Site_Name-Number-Type-Article_Name" part and get the information I want out of that, but for whatever reason it's not getting the PHP variables in the URL "webmaster_id=xxxx&track=TRACK" ... it's completely ommiting it when passing the information. Here's my htaccess: RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond $1 !^(.*jpg) # RewriteRule (.*) index.php?urlVariables=$1 [QSA,L] Any help appreciated! edit ------- Actually found an easy solution: Options +FollowSymlinks RewriteEngine On RewriteCond %{QUERY_STRING} foo=(.*) RewriteRule ^grab(.*) /page.php?bar=%1 Thanks anyways! eHacked fucked around with this message at 00:14 on Mar 18, 2009 |
# ? Mar 18, 2009 00:05 |
|
I'm not sure the QSA flag works as expected when you're already manually rewriting into a query string. I don't too regexes very often, so I don't know if/how well this would work:code:
Zorilla fucked around with this message at 00:29 on Mar 18, 2009 |
# ? Mar 18, 2009 00:18 |
Is there a way to easily echo the compiled form of a prepared statement for PDO? I find myself frequently wanted to do this when developing and it gets annoying having to echo all the bound variables and manually replace them. I just want to quickly paste the compiled statement into phpMyAdmin or whatever.
|
|
# ? Mar 20, 2009 04:59 |
|
Nope :| At least I gave up trying to find a decent way after looking for a good bit.
|
# ? Mar 20, 2009 06:19 |
|
How would I test to see if a database query returned no results? code:
I've done if ($row == FALSE) but I can't get it set up right so I can use the while loop with it. PS Im new to php/mysql. I do know a bit about programming though. Sylink fucked around with this message at 06:35 on Mar 20, 2009 |
# ? Mar 20, 2009 06:31 |
|
Sylink posted:How would I test to see if a database query returned no results? What you're doing already should do that. mysql_fetch_array will return null, which means $row will be assigned null, which means the while loop will not execute. If that doesn't seem to be working, just test if($result) outside your while loop.
|
# ? Mar 20, 2009 06:40 |
|
Sylink posted:How would I test to see if a database query returned no results? php:<? if (mysql_num_rows($result) == 0) ?>
|
# ? Mar 20, 2009 13:50 |
|
Standish posted:
This worked great. Thanks.
|
# ? Mar 20, 2009 21:02 |
|
What is the common way to set up a dynamic page with php? By this I mean I have an index.php which contains the basic layout and I have the content in separate php files. I have seen where you can use the page variable and switch statements but I can't get it to work right. If this question is too long and anyone knows a good tutorial/resource on it I would take that. In this case I have form included on the index page. If submitted it queries a database and returns some data. I want the search result to appear in the same html template basically.
|
# ? Mar 21, 2009 21:52 |
|
Sylink posted:What is the common way to set up a dynamic page with php? By this I mean I have an index.php which contains the basic layout and I have the content in separate php files. Most people use a header.php and footer.php and include them at the top and bottom of each file. I usually do this instead because it's a little more flexible.
|
# ? Mar 21, 2009 23:35 |
|
I'm trying to learn PHP OOP ... I am using this online tutorial: http://www.killerphp.com/tutorials/object-oriented-php/index.php Everything was going great until the constructor part. index.php has this code: php:<? include("class_lib.php"); $stefan = new person("Stefan Mischool"); $jimmy = new person("Nick Waddles"); echo "Stefan's full name: " . $stefan->get_name() . "<br />"; echo "Nick's full name: " . $jimmy->get_name(); ?> php:<? class person{ var $name; function __construct($persons_name){ $this->name = $persons_name; } function set_name($new_name){ $this->name = $new_name; } function get_name(){ return $this->name; } } ?> quote:Stefan's full name: What the gently caress is going on? I have appx. 0 knowledge in OOP ... but the syntax looks fine to me, and no errors are returned so I'm assuming some shady stuff is going down! And since this tutorial looks to be failing me ... can anyone else recommend a good, simple, online and free tutorial to learn OOP in PHP? eHacked fucked around with this message at 18:36 on Mar 23, 2009 |
# ? Mar 23, 2009 18:34 |
|
That ought work. Change the include to require just to verify it is getting the person class definition. Failing that change __construct to person , which is the alternative constructor syntax (use class name as method name) and see if that works.
|
# ? Mar 23, 2009 18:47 |
|
duck monster posted:That ought work. Change the include to require just to verify it is getting the person class definition. Hi, thanks, changing the constructor name seemed to work... would this have anything to do with the server I'm learning off of running php 4?
|
# ? Mar 23, 2009 18:52 |
|
|
# ? May 15, 2024 08:00 |
|
eHacked posted:php 4 Don't do this to yourself. Anything before PHP5 is junk.
|
# ? Mar 23, 2009 18:54 |