Jump to content

Zane

Administrators
  • Posts

    4,362
  • Joined

  • Last visited

  • Days Won

    11

Everything posted by Zane

  1. Just in case you are using them... Short tags are no longer enabled by default, you have to enable the manually in the php.ini file. <?="Hello World" ?> <? echo "Hellow World"; ?>
  2. It's as simple as adding an exclamation mark. You didn't supply your code but I imagine it looks like this if( preg_match_all ("/^([a-z0-9-_\.]+@[a-z0-9-_]+\.[a-z]{2,3})$/", $line) ) add the ! exclamation point before preg_match* if( ! preg_match_all ("/^([a-z0-9-_\.]+@[a-z0-9-_]+\.[a-z]{2,3})$/", $line) ) Or, if you have something against exclamation marks, you can check if it is false if( preg_match_all ("/^([a-z0-9-_\.]+@[a-z0-9-_]+\.[a-z]{2,3})$/", $line) === FALSE) if( preg_match_all ("/^([a-z0-9-_\.]+@[a-z0-9-_]+\.[a-z]{2,3})$/", $line) !== TRUE)
  3. Because that token is your key to their information, their profile, their demographics; everything you need to keep up with your incoming traffic without the hassle of storing it yourself. Storing a session is easy. Getting users to create an account on your site; not so much. User friendless is key to a successful website, otherwise it's like one of those extremely complicated adding machines from the 20's, with liquid based atticuses and hand-carved wooden levers and gears. There's is no substitute for a $_SESSION, it has one purpose in life, and that is to remain accessible until the site and browser sessions are terminated.
  4. Zane

    The Dane

    So you were how old when you made your first website? 7? 6?
  5. Make sure $diary_entry is free of any and all apostrophes and backslashes.
  6. Are the files on the same server as your script? If so, there is no reason to use FTP at all. You can use glob() to get an array of files.
  7. This is one of the many reasons you shouldn't store multiple values as everyone is suggesting. There are too many things that can go wrong with a setup like this. To answer you question though, No. Not in the way that you are trying. The only way to get Item 2, is to receive all of the info and use PHP to explode by the comma and then it's as simple as reading $thedata[1] Ideally, you want to do any and all filtering on the MySQL side first, which is why you asked this question to begin with. So do yourself a favor and read a tutorial on normalization, table joins, foreign and primary keys, etcetera. Start by reading this thread here, http://stackoverflow.com/questions/2800104/sql-query-with-multiple-values-in-one-column
  8. No, you do not have to download PHP if your service provider AKA host has it installed for you already, nor should you have to download mysql. Hosting companies sell their hosting space with common new technologies for a reason, to make it simpler for an individual to make a website. I suppose you could call a hosting package a kit. Any kind of kit that you buy, whether it's a model airplane building kit or a camping kit, the word 'kit' indicates that the minimum tools required are included.
  9. Yes, I was also pretty off-put by that wording. Unless you're traversing through the session files stored in your servers tmp directory, I only know of one $_SESSION to loop through, and that is the current one. I imagine about the same thing as requinix... $_SESSION['sessionOne'] = range (5,5000); $_SESSION['sessionTwo'] = range (5,6000); $_SESSION['sessionThree'] = range (5,7000); Provide code if you're asking questions about it. Seven tables full of nothing but traits? Like attributes? Key/Value pairs?I sense a non-normalized db structure, but that's a whole different can of worms.
  10. Without any code, I would suggest that you order all your arrays descending and grab the first element in each array. Boom, max values collected!
  11. PHP variables begin with a $ dollar sign.
  12. If you have the signup_date column set to a DATE type, then there's no reason to use PHP. SELECT id, signup_date FROM pdata WHERE signup_date >= DATE_SUB(NOW(), INTERVAL 30 DAY)That way, ONLY the users whose signup_date is a month old will be returned.
  13. Seriously? Three years later I get corrected.
  14. Using this 5 year old example, http://us3.php.net/manual/en/function.array-diff-key.php#82257 should help. Using that array_unique_diff function, you should be able to have an array of all the unique and different keys. Then you can iterate through those with a loop and add them to each array.with a value of 0. If I understand you correctly. function array_unique_diff ($array1, $array2) { return array_merge(array_diff_key($array1, $array2), array_diff_key($array2, $array1)); } $a = array ( "one" => 1, "two" => 2, "three" => 3 ); $b = array ( "one" => 56, "two" => 2, "four" => 19 ); $missingKeys = array_unique_diff ( $a, $b ); foreach ( $missingKeys as $key=>$val ) { $a[$key] = 0; $b[$key] = 0; } That should change $a and $b to be $a = array ( "one" => 1, "two" => 2, "three" => 3, "four" => 0 ); $b = array ( "one" => 56, "two" => 2, "three" => 0, "four" => 19 );
  15. Firstly, the sole purpose of using PHP (or pretty much any programming language) is to create dynamic content. That being said, I still have no idea what you are asking. Where are you searching from? Where are these "words"? Are you talking about querying a database? Your question is very unclear.
  16. No need to pass by reference, because mainly, it will not solve your problem. Leave the ampersand (&) out of there and check this out. You're using the following foreach syntax foreach ( $r as $result ) Judging by what follows, $r is a multidimensional array, right,... meaning $result will be a sub array of $r..... right. You want to preserve the formatted data, from what I gather. Therefore, if you were to pass anything at all by reference, it would be the main array $r. But,... you are not within a function, so the scope of your variable has not changed. Therefore, you can edit $r within the foreach WITHOUT an ampersand (&), without any kind of referencing whatsoever! In order to preserve your data, you need to know exactly which item in the $r array to edit, ...and the easiest way to locate data in an array is with the key. Fortunately, foreach has slightly different syntax that allows you to retrieve the key as well. So now, you should understand why this way is much much better. foreach ($r as $key=>$result){ // format results if ((array_key_exists('sr_number', $result)) && ($result['sr_number'] == "")){ $r[$key]['sr_number'] = " "; } if ((array_key_exists('start_dt_tm', $result)) && ($result['start_dt_tm'] !="")){ $r[$key]['start_dt_tm'] = date("m-d-y h:i A", strtotime($result['start_dt_tm'])); } } Without knowing exactly what you array looks like, I can't guarantee that the above code will work. I merely wanted to point out that the key of the array IS accessible. Even if you were not using a foreach loop, rather a while loop or something else, you could use PHP's key function and store it into a variable.
  17. Instead of concatenating several quoted and double quoted strings together, why not make things easier on yourself and use a HEREDOC?
  18. "Apache's php.ini" otherwise known as a server side include allows Apache to use PHP whenever it needs it. The CGI way is quite old. When using this method of PHP installation, you must call the PHP interpreter when you want to use it. In other words, the CGI way would be for those who do not intend to use PHP much, if at all. FastCGI is a mix of the two, which I have yet to try. Most PHP-heavy websites should be using the Apache SSI installation of PHP. More information here http://blog.layershift.com/which-php-mode-apache-vs-cgi-vs-fastcgi/
  19. Do the following? ... what is following what?
  20. Only in the file which phpinfo says is THE file. PHP.ini is nothing more than a text file with a list of settings, it doesn't matter whatsoever where the file is located on your server so long as: a ) PHP has permission to access it b ) Apache is pointing to the correct path of the file There's no "correct" place to keep your php.ini file to answer your question. Some people even have them in their webroot along with all of their other web-accessible files.
  21. Maybe I'm confused, but.. Chrome comes pre-equipped with a debugger..... https://developers.google.com/chrome-developer-tools/ Using the console tab, you can easily type alert(checkacct); and press enter, and it will work. You can even call your function.
  22. While that could be possible, bluemonde. You would be the only one that can know. I didn't rewrite you entire script or anything. I simply made it more human readable. So any and all syntax errors, variable declarations, server settings, php version, apache version, operating system, etcetera... are on you. If you open the source, using view source (or Chrome's development pane), you should be able to see for sure whether or not $check went through.
  23. Although I didn't test the query at all, I've came across headaches in the past where I would get an invalid field error. or something something is ambigous. We always had to use two dots in my DB Admin class... databaseName.tableName.fieldName
  24. Where are you planning to use the $country variable? From what I understand from your posts, you want to use it in your query, which have yet to see. In that case, country should be used in the WHERE clause of the SQL query.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.