|
Agrikk posted:if I do a print_r($SystemArray) I get: If what you're looking to do is have an array search that probes down values that are arrays themselves, you'll probably have create one. Here's one I quickly found in the comment section of php.net's array_search docs: code:
|
# ? Oct 1, 2009 19:20 |
|
|
# ? May 16, 2024 17:14 |
|
So clearly I am doing something wrong and don't understand arrays Why doesn't this work? php:<?php //load up multidimensional array with "xx" for ($aa=0; $aa < 2;$aa++) { for ($bb=0; $bb < 2;$bb++) { for ($cc=0; $cc < 2;$cc++) { $SystemArray[$aa][$bb][$cc]="xx"; } } } //change one element to "Hello" $SystemArray[1][1][1]="Hello"; //print array to be sure it's there print_r($SystemArray); //find "hello" $IsThere="no"; for ($aa=0; $aa < 2;$aa++) { for ($bb=0; $bb < 2;$bb++) { for ($cc=0; $cc < 2;$cc++) { if ($SystemArray[$aa][$bb][$cc]==="Hello") $IsThere="yes"; } } } if ($IsThere="no") { echo "not found\n"; } else { echo "found\n"; } ?>
|
# ? Oct 1, 2009 19:22 |
|
Agrikk posted:if ($IsThere=="no")
|
# ? Oct 1, 2009 19:25 |
|
Standish posted:Also using strings "yes" and "no" instead of booleans is just shameful. Getting off topic for a second, what does it matter if I use strings or booleans? Is it a performance issue or something? Agrikk fucked around with this message at 19:43 on Oct 1, 2009 |
# ? Oct 1, 2009 19:30 |
|
Agrikk posted:Getting off topic for a second, what does it matter if I use strings or booleans? Is it a performance issue or something? code:
quote:Oh motherfucker. Using booleans instead of strings actually made it all work. Standish fucked around with this message at 20:04 on Oct 1, 2009 |
# ? Oct 1, 2009 19:41 |
|
Standish posted:It's slower to use strings, yes, but the main thing is style and avoiding horrible bugs like [php]$a = "no"; Thanks for your help Standish. I just realized that that was my error. I always get tripped up between =, == and ===. Meh.
|
# ? Oct 1, 2009 19:45 |
|
So lets say I more or less wanted a user to be able to set a date that they will receive an email and then have my script send it at that date. The thing is it needs to be accurate down to a few minutes. What would the best method to go about doing this? Cron job + mysql is what I was thinking through research but I havnt necessarily worked with these before but it wont be too hard for me to pick up on.
|
# ? Oct 2, 2009 16:03 |
|
I'm upgrading my PHP framework, and I was thinking about URL routing / management. One thing I really liked about Django was urls.py (which is weird because that is normally what everyone hates about Django) and I was wondering if a similar system would lend itself to PHP, and whether or not it is a good way to do things. At the moment, I am taking the first segment of the URL and querying a database table of "apps" to match the slug and load the relevant controller. A url router array would probably be a nicer way of doing it as it means I can cut out the database query and use regex for more flexible urls strings. Does anyone have a particularly nice way in which they handle url management with their apps? Are there any downsides or performance issues to using the system mentioned above?
|
# ? Oct 2, 2009 16:31 |
Hanpan posted:I'm upgrading my PHP framework, and I was thinking about URL routing / management. One thing I really liked about Django was urls.py (which is weird because that is normally what everyone hates about Django) and I was wondering if a similar system would lend itself to PHP, and whether or not it is a good way to do things. At the moment, I am taking the first segment of the URL and querying a database table of "apps" to match the slug and load the relevant controller. A url router array would probably be a nicer way of doing it as it means I can cut out the database query and use regex for more flexible urls strings. I use something similar, only I don't define the list of valid objects in a database, I just do it in my main controller that handles the URL parsing. I set it up to handle plural/singular and route it to the same object controller (ie domain.com/users/browse or domain.com/user/profile). The only downside I see to the way you are doing it is that it's querying the database every time. For something that doesn't hardly changes, either just hard code it in or use memcache. Other than that my url routing isn't very fancy, it's basically a bunch of poo poo slapped around an explode("/", $url).
|
|
# ? Oct 2, 2009 19:26 |
|
Hanpan posted:Does anyone have a particularly nice way in which they handle url management with their apps? Are there any downsides or performance issues to using the system mentioned above? Look at routed_uri().
|
# ? Oct 2, 2009 20:10 |
|
Funnily enough, I have just been rooking through Kohana's source. It's pretty well coded by drat they love singletons.
|
# ? Oct 2, 2009 22:57 |
|
Is there a retard's guide to regular expressions or a book on it? I'm trying to do something with an xml file that has tags like code:
I've always found myself frustrated finding the correct expression to match the pattern I need so I just wanted to buy a book or something that starts off easy but gets into examples and what not. cLin fucked around with this message at 03:54 on Oct 3, 2009 |
# ? Oct 3, 2009 03:51 |
|
Don't use regexps to parse xml.
|
# ? Oct 3, 2009 04:19 |
cLin posted:Is there a retard's guide to regular expressions or a book on it? I'm trying to do something with an xml file that has tags like I don't understand why you would even attempt to use regular expressions. Did you even try searching "php xml" in Google?
|
|
# ? Oct 3, 2009 04:35 |
|
Plorkyeran posted:Don't use regexps to parse xml. Aw, c'mon. I do it all the time. Granted, I'm usually checking for the existence of "AuthSuccess" in the document and I don't care about the rest of it. But yeah, if you want to keep the structure and all you might need to use an XML parser.
|
# ? Oct 3, 2009 04:36 |
|
I'd recommend trying SimpleXMLElement first. It's easy to use and works great for most situations where you need to read XML.
|
# ? Oct 3, 2009 06:03 |
|
Ok, sorry guys. I'll look into XML parsers now..still, I'd like to learn regular expressions since it looks scary but powerful. I'd still like some recommended reading.
|
# ? Oct 3, 2009 08:38 |
|
cLin posted:Ok, sorry guys. I'll look into XML parsers now..still, I'd like to learn regular expressions since it looks scary but powerful. I'd still like some recommended reading. http://regular-expressions.info
|
# ? Oct 3, 2009 08:47 |
|
cLin posted:Ok, sorry guys. I'll look into XML parsers now..still, I'd like to learn regular expressions since it looks scary but powerful. I'd still like some recommended reading. Not really a reading resource but this site was priceless when I was learning regular expressions. http://gskinner.com/RegExr/
|
# ? Oct 3, 2009 15:36 |
|
I am new at this so please forgive. I had another post in here and I finished that up well. Ive decided I want to implement a stats system and I planned ahead for this, well I thought I did at least. I have a date_submitted and a date_completed field. Both are INT fields using unix timestamps, I have a 3rd field that contains the task of which there are 3 types and a 4th field that says completed or not. I already figured out how to use count to get the number of records to match them by type and spit out the results but I cant figure out exactly how to get records ONLY from the last 7 days that are marked completed. I can get completed and narrow it down to type but not to time. This might belong in an SQL thread I guess now I think about it? Can anyone point me in the right direction for this? Im happy with just a mysql link.
|
# ? Oct 5, 2009 14:36 |
|
insidius posted:I already figured out how to use count to get the number of records to match them by type and spit out the results but I cant figure out exactly how to get records ONLY from the last 7 days that are marked completed. I can get completed and narrow it down to type but not to time. code:
|
# ? Oct 5, 2009 15:06 |
|
Standish posted:
Thank you! I figured that was but my problem was never being good at maths or programming was that I was not sure how to structure the last part of the query. There was a reason I did not use the mysql DATETIME but I cant remember for the life of me why now...
|
# ? Oct 5, 2009 15:10 |
|
Hello friends I am trying to pass some variables via exec. Here is my code: code:
code:
Well obviously I'm missing something because no variables seem to be passed!
|
# ? Oct 6, 2009 17:55 |
|
eHacked posted:Hello friends Are you using the CGI php binary instead of the CLI PHP binary? http://www.php.net/manual/en/features.commandline.php
|
# ? Oct 6, 2009 18:59 |
|
Standish posted:Are you using the CGI php binary instead of the CLI PHP binary? PHP 5.2.5 (cli) (built: Feb 4 2008 17:09:00) Copyright (c) 1997-2007 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies with the ionCube PHP Loader v3.1.34, Copyright (c) 2002-2009, by ionCube Ltd., and with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies with Zend Optimizer v3.3.0, Copyright (c) 1998-2007, by Zend Technologies Showing cli. I can't figure out what the problem is >=[
|
# ? Oct 6, 2009 20:28 |
|
Is this enabled in your php.ini file?code:
|
# ? Oct 7, 2009 00:18 |
|
Let me preface this post by saying I know almost nothing about PHP. I am building this website for an academic workshop and the professor wants me to have an interactive form that students will fill out, which will then be emailed to him. After much tinkering and research I guess my best bet is to use PHPMailer. The first step to using it seems to be modifying the php.ini file(?). I don't think I have access to this since our webspace is just virtual hosting through my school's (lovely) IT department. Is this step absolutely necessary? If so is there any work around?
|
# ? Oct 8, 2009 01:54 |
|
Sirotan posted:Let me preface this post by saying I know almost nothing about PHP. You are opening a can of worms, especially if you are new to programming. If all you want to do with PHP ever is to create this form, do it a different way. You could create a free google apps account and create a form online through there. I haven't messed around with wordpress, but you could probably create a free blog and set it up to send out forms. There has got to be online services that do this for a low cost if not free. However, if you are experienced with programming, just create a simple test.php page with something like <?php echo 'taco' ?> in it and load it up and see if it works. If it does then try out the mail() command - http://us.php.net/manual/en/function.mail.php If the mail command works then you aren't going to need to modify the php.ini, and if you are just sending some text it should work just fine without you needing to mess with php mailer.
|
# ? Oct 8, 2009 02:26 |
|
hopefully somebody can tell me what the gently caress i'm doing wrong. I've tried googling this, trying all sorts of things, and nothing seems to work and it's frustrating. It looks like i'm doing the same things everybody else is doing but i'm obviously loving something up. I cannot get my sessions to last for more than a few days. I want to stay logged in indefinitely or until i destroy the session. unfortunately randomly every few days I'm logged out, even though the cookie says 5 years or something crazy, the session id in the cookie is still in my tmp folder. help this is basically what i have php:<? session_name("PHPSESSID"); session_set_cookie_params(155520000,"/"); session_start(); print $_COOKIE['PHPSESSID']; if (isset($_SESSION['userid'])) { // Do poo poo } else { // Display Login } ?> Included the screenshot of the cookie, the printed cookie, and the tmp folder session in case any of that is relevant
|
# ? Oct 8, 2009 03:45 |
|
Begby posted:You are opening a can of worms, especially if you are new to programming. If all you want to do with PHP ever is to create this form, do it a different way. Yeah after several hours of frustration I was able to just put up a simple form mailer using mail() that worked, its just that it isn't very elegant and I don't know if I can use that send attachments. Also reading a few guides it seems that isn't a very secure way of handling it. I will definitely check out google aps, we are actually planning on putting in a wordpress blog in the future but he wants this form up like now so I don't think I will have time to mess around with that. Basically, the guy I'm making this site for is totally computer illiterate, he initially wanted me to create something like cTools, U of M's online coursework management system, an application my university uses for its 50,000+ study body, just so that the MAYBE 150 students that will apply to this workshop could check on the status of their applications online. His expectations are completely unrealistic, so he is gonna have to be happy with what I give him or he can hire a bunch of dedicated coders and spend up the wazoo to get what he really wants.
|
# ? Oct 8, 2009 04:19 |
|
crabrock posted:
|
# ? Oct 8, 2009 08:27 |
|
I already tried that :\ edit: would session auto start do anything?
|
# ? Oct 8, 2009 09:19 |
|
crabrock posted:I already tried that :\ From vague memory, auto_start just specifies whether to create a session on every request, rather than just those that call session_start()
|
# ? Oct 9, 2009 03:39 |
Murodese posted:From vague memory, auto_start just specifies whether to create a session on every request, rather than just those that call session_start() Why wouldn't that be a php.ini setting?
|
|
# ? Oct 9, 2009 07:22 |
|
fletcher posted:Why wouldn't that be a php.ini setting? Do you mean why wouldn't that be on by default? Overhead in various areas. If you are doing disk based storage that's an extra filesystem read/write *every* request, even if it's not needed. If your session save path isn't partitioned and you have a fairly busy site you might be stressing your file system with too many files in a directory. If you have db based storage that's an extra db read/write every request. Plus that is extra data in the HTTP header the client has send each time.
|
# ? Oct 9, 2009 17:36 |
Anveo posted:Do you mean why wouldn't that be on by default? Overhead in various areas. If you are doing disk based storage that's an extra filesystem read/write *every* request, even if it's not needed. If your session save path isn't partitioned and you have a fairly busy site you might be stressing your file system with too many files in a directory. If you have db based storage that's an extra db read/write every request. Plus that is extra data in the HTTP header the client has send each time. It was meant as a joke.
|
|
# ? Oct 9, 2009 19:27 |
|
So does nobody know why my sessions aren't keeping? is it something i should bring up to my host? I wanted to see if there was anything wrong with my code, but nobody has said anything either way.
|
# ? Oct 10, 2009 03:08 |
|
crabrock posted:So does nobody know why my sessions aren't keeping? is it something i should bring up to my host? I wanted to see if there was anything wrong with my code, but nobody has said anything either way. http://phpuserclass.com
|
# ? Oct 10, 2009 04:26 |
|
crabrock posted:So does nobody know why my sessions aren't keeping? is it something i should bring up to my host? I wanted to see if there was anything wrong with my code, but nobody has said anything either way. Is your host erasing the contents of /tmp on the server every couple of days? Or is there a cron job that goes in there and deletes everyting that is x days old? The session ID cookie is used by PHP to find and restore the session server side. If you are saving a logged in value on the server, and its gone, then PHP will makre the user as logged out. You might want to create your own session handler that saves the session data to a db if you can, that would fix this problem.
|
# ? Oct 12, 2009 19:21 |
|
|
# ? May 16, 2024 17:14 |
|
Begby posted:Is your host erasing the contents of /tmp on the server every couple of days? Or is there a cron job that goes in there and deletes everyting that is x days old? Zebra Framework has a good Sessions class. http://stefangabos.blogspot.com/search/label/Sessions%20Management%20PHP%20Class%20Download
|
# ? Oct 12, 2009 23:13 |