StormTheGates
Members-
Posts
170 -
Joined
-
Last visited
Everything posted by StormTheGates
-
Ah ok, does the directory need to be 777?
-
Hello everyone, I am trying to implement a fast user online script. The purpose of this topic is dual. First I have this code: $session_path = session_save_path(); echo "Path is $session_path"; This only returns the text "Path is" and then no path. Any ideas why? Also with the method I am using it can only count the number of sessions. Any idea how I could pull out usernames and list them to?
-
And its now 2:15 am for me. So its drinking time for me. Night all.
-
I am not sure to be honest. I never use files for anything if I am honest with you. I just use my database and its faster and safer.
-
I dont believe there is a native PHP function for that. However I do think it would be possible with some nasty code.
-
Fair enough. Make a file called liked quotes.txt and put every quote on an INDIVIDUAL LINE! Thats very important. The code I am going to give you will read 1 line at a time from the file. Replace the stuff at the top with this: $quotes = array(); $file = "quotes.txt"; $fh = fopen($file, 'r'); $i = 0; while(! feof($file)) { array_push($quotes, gets($file)); $i++; } fclose($fh); $rand = rand(0,$i); $say = $quotes[$rand]; No promises, but that should work.
-
Reading from the file could be harder than putting it in a database and grabbing a random one from the db. Do you really want me to type out how to call from a file? Ill do it if you want to go that route, just saying calling from the db might be easier.
-
Press the solved button then so we can all feel shiny We are also nerds, not geeks by the way.
-
I decided I would rather help you out than sleep. I also figured out the solution <?php $bigarray = array('<n>blue</n>', 'red', '<n>green</n>', 'red'); $namearray = array(); foreach($bigarray as $t){ if(substr(htmlspecialchars($t), 0, 2) == '&l'){ $takeout = array("&l"); $name = str_replace($takeout, "", $t); array_push($namearray, $name); } } ?> You see I encoded the HTML shit, and then &l which was the representation of <n>. So huzzah it displayed fine for me in my web browser with the print_r command. Hope it works for you
-
Something very odd is happening that may throw it off. When I ran this code on my server: <?php $bigarray = array(0 => '<n>blue</n>', 1 => 'red', 2 => '<n>green</n>', 3 => 'red'); $namearray = array(); foreach($bigarray as $t){ if(substr($t, 0, 2) == "<n>"){ $takeout = array("<n>", "</n>"); $name = str_replace($takeout, "", $t); array_push($namearray, $name); } } ?> I noticed that it stripped out the <n>. Infact the whole < > thing seemed to screw up the array. I dont know why this is. Its most likely my the browser trying to do some HTML stuff with it when printing out. I have to go to bed soon, since its 1:20, so I am gonna have to leave ya to figuring it out. I hope what I put in helped, and you can figure it out. That should hypothetically be all you need. Best of luck ~StormTheGates
-
Yea thats what I meant. In that case do something like this perhaps? foreach($bigarray as $t){ if(substr($t, 0, 2) == "<n>"){ $takeout = array("<n>", "</n>"); $name = str_replace($takeout, "", $t); array_push($namearray, $name); } } My foreach skills are very rusty since I never use them, so it may need some refining. Basically all that does is check each array element in $bigarray's first 3 letters to see if they are <n>. If they are then it will strip out the <n> and the </n> and push just the username into the name array. If not, it will just move onto the next array element.
-
Will the <n> part be unique to only the username? There wont be any more <n> preceding another array element?
-
Are the usernames all gonna be different?
-
Ok well in that case maybe make it so something is stored before every username in the array, then use array_keys. For example: If you had it so that the word "Wolf" was placed in the array key before every username then you could theoretically do this: $keyarray = array_keys($array, "Wolf") //Returns an array with all the key numbers of the Wolfs $i = 0; while($i <= $usernumber){ $t = $keyarray[$i] + 1; $name = $array[$t]; array_push($namearray, $name); } So thus with a hierarchy like this in your array: Array0 = Something Array1 = Wolf Array2 = Username Since the Wolf is always 1 key before the username, when you add 1 to the keys you pulled and then draw out of the big array you would theoretically always get the username. Of course it could be anything before the username key, as long as its constant.
-
I dont know the SMF forum structure. Just find whatever file has the code for the banner in it and then put that at the top.
-
Since it is occuring in regular intervals I would do something like this //Code to find out how many users are in the array $i = 0; $b = 0; $people = array(); while($i <= $totalusers){ array_push($people, $bigarray[$b]); $b = $b + $interval; } I could be getting it all wrong of course. But if the array has a set interval between each name you can just pull those values out of the array and then push them onto the other array.
-
[SOLVED] PHP Command Line (php.exe) help
StormTheGates replied to techiefreak05's topic in PHP Coding Help
Try php -help ? -
Hmmmmmmmm ok. Well here is what a sample page would look like: <?php $quotes = array("Saying1", "Saying2", "Saying3", "Saying4"); $rand = rand(0,3); $say = $quotes[$rand]; ?> <table border=1> <tr> <td style="background:url(http://www.yoursite.com/banner1.jpg)"><?php echo "$say"; ?></td> </tr> <tr> <td>Hey all, this is some text from my website!</td> </tr> </table>
-
Ok then here is the code for the saying: $quotes = array("Saying1", "Saying2", "Saying3", "Saying4"); $rand = rand(0,3); $say = $quotes[$rand]; Then you should do something like this I guess for the image: <tr> <td style="background:url(http://www.yoursite.com/banner1.jpg)"><?php echo "$say"; ?></td> </tr>
-
My pleasure.
-
I recommend OFF unless you really need them. They are a security risk.
-
Sure easily. Is it going to be placed over an image or just the text?
-
Heres something I cooked up: <?php $something = $_POST['quote']; $replace = array("javascript", "html", "body"); $replaced = str_replace($replace, "...", "$something"); echo "$replaced"; ?> Should work fine. Just add array elements to $replace with words you want to be replaced.
-
I am trying to start my HTTPD service. However it seems PHP is killing it. I get this error: httpd: Syntax error on line 53 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: undefined symbol: sapi_globals Any ideas?
-
I am having problems installing PHP5 on my CentOS server. Ive tried following the instructions for installing PHP with Apache 2.x in the INSTALL file in the .tar.gz PHP package to now avail. It all went smoothly until the last step when I start Apache. I get this error: httpd: Syntax error on line 53 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: undefined symbol: sapi_globals Any ideas? I dont want to install PHP via Yum because that installs php 4 and I want php 5. Any help would be greatly appreciated.