Jump to content

maxim

Members
  • Posts

    48
  • Joined

  • Last visited

    Never

Everything posted by maxim

  1. hay ifa or any one else. i was reading up on the python prgramming language and long story short its a strange language! it calls arrays "lists" any way they have a inbuilt kinda thing called sliceing. to only output a certian number of elemnts in a list (or array). i checked out the php manual and sure enough php has a array_slice() fuction. take a look http://au2.php.net/function.array-slice so with out testing it i assume this will produce the same results [code]$first_three = array_slice($array, 0, 3);[/code] what do you guys think of the array_slice() fuction ? is it better to use it ? or just stick with looping through a bigger array ans using break; to stop the loop once you have your deired output ? edit:: actualy i dont think it works on assoc arrays :(
  2. hah thats a very smart way to do it. its easyer to read and understand also so ill use it. i perfer foreach loops also. how ever theres a small but. its actualy loops through the array four time not three. be cause $i starts off as 0. so. you need to assign a value of 1 to $i, out side the loop. [code] $i = 1; foreach ($array as $key =>$val) {           print "$key - $val<br  />";           if($i == 3) break;           $i++; } [/code] of course you could just use 2 insted of three. like you did in your original post. [code] if($i == 2) break; [/code] but i set the value of $i as the code is more logical but yeah thanks heaps for that Ifa. the break; keyword is definalty one to remember
  3. ahh yes i how ever had a accoiative array. with diffrent strings as the keys
  4. hay that worked. thanks - ive never used the list(); function before because i was under the impression that foreach was the best way to loop through arrays. thanks again this should help me in the future
  5. Hi i have a accoiative array. it holds 10 elements. i loop through it like so [code="php"] foreach ($array as $key =>$val) {           print "$key - $val"; } [/code] this prints out the 10 values. i would like to only prind out lets say 3. how would i go about doing this. i tryed putting the foreach loop in a while loop. but it either prints out the 10 element array 3 times. or it prints out the first element 3 times.
  6. you need to install GD. for example i have php version 5 on ubuntu. but the ubuntu team took GD out of PHP and have it as a seperate install. go to redhats package manager and search for "php gd" make sure you get the GD version that [u]matches[/u] you PHP version.
  7. i dont know of any scripts. but if its something custom then looks into PHP's GD extention. It has the abilty to do what you want. you will need to read up on GD, so hit up google
  8. i know you can do this [code]//enable the .png image to retain its transperant properties imageAlphaBlending($image, false); imageSaveAlpha($image, true);[/code] basicly if you using existing image which already has transperancey by default it will look black. so by adding that code it makes it transparent. if you use imagecolortransparent() it only makes that 1 color transparent and is only good for low res 'blocky' images, hope that helps. heres a image i made with the code i posted. as you can see the shadow is semi transparent something that is not possible with imagecolortransparent() [a href=\"http://maximhome.no-ip.org/blog/?p=5\" target=\"_blank\"]http://maximhome.no-ip.org/blog/?p=5[/a]
  9. that wroked perfectly. mktime eh i am pretty dissapointed tho. i would have like to be pointed in the right direction insed of being told the answer. but thanks again anyway
  10. Hi i would like to display a dynamic "countdown" on screen. basicly i get the current timestamp. and have a set future time stamp.If i subtract the current time stamp from the future one am i right in believeing that i have the number of seconds left untill that future time is reached ? if so i am totaly confuesed as to how to perfom maths on it. for example i want to display the weeks,days,hours and mins left untill the future date. i can get the weeks by doing somethink like the following [code]$timeleft_timestamp = $future_timestamp - $current_timestamp; $weeks = $timeleft_timestamp / 60 / 60 / 24 / 7;[/code] is this correct. if so how do i go about getting the days,hours,mins. im left with a number with alot of decimal places should i just use the round() function. will this be accurate ?
  11. [!--quoteo(post=385968:date=Jun 20 2006, 09:34 PM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ Jun 20 2006, 09:34 PM) [snapback]385968[/snapback][/div][div class=\'quotemain\'][!--quotec--] If you don't have access to it through a GUI such as cPanel, you'd need to have SSH access to write the contab manually. [/quote] yeah i do have the access to the cPanel GIU and as it turns out it works ! here the entery into cron tab i made [code]00 * * * *  php /home/MyUserName/public_html/script.php[/code] i belive it updates once every hour/day/week/year. how ever i test all my scripts localy before i upload them so when i put that crontab entry into my own local machines crontab it didnt work ! see how i have the word "php" before the path to my script. what dose crontab do when it sees that ?
  12. i have the same problem. i have a few scripts which generate a image. and out that image to a file. the file only gets updated when the script runs. My free host supports cron jobs. but im lost as to how to get it working. all tutorials i read say u need root acces or lynx which my host dose not have. any ideas on how to execute a PHP script form cron
  13. maxim

    PHP and GD

    the font comes from a file that is located in the same directory as the script. those images should work... as i alrady stated mt PHP version my GD versions are as follows local server =GD Version 2.0 or higher remote server = GD Version bundled (2.0.28 compatible)
  14. maby the book that was suggested to you before might be the best place to start. but for on-line help this may be relevent [a href=\"http://hudzilla.org/phpbook/read.php/6_0_0\" target=\"_blank\"]http://hudzilla.org/phpbook/read.php/6_0_0[/a] i have also heard very good things from many diffrent sources about the "sams teach yourself c++ in 24 days" i know its c++ but apperntly it dose a good job of explaining OOP. i myself have not had any reason to learn OOP so i havent read that book.
  15. Hi, i made a small script which reads a HTML file and stores some text from it. It then outputs that text onto a image. i tested the script on my local apache server with PHP Version 5.1.2. heres is a copy of the final result. [img src=\"http://maximhome.no-ip.org/images/local.png\" border=\"0\" alt=\"IPB Image\" /] here is a copy of the exact same script running on my remote web server using PHP Version 4.4.2 [img src=\"http://maximhome.no-ip.org/images/remote.png\" border=\"0\" alt=\"IPB Image\" /] there is a obvious diffrence between images. its the text output. on the remote web server is displayed much better with even spacing between letters in the text. any ideas on why this is happening. my guess is its the diffrent version of eith PHP or GD on the diffrent servers what do you guys/girls think ? the dynamic version of the image can be foun here [a href=\"http://maximhome.no-ip.org/picture.html\" target=\"_blank\"]http://maximhome.no-ip.org/picture.html[/a]
  16. maby they didnt make it with visual c++
  17. putting the "echo" statment made it work - thanks alot for the quick reply and solution! can believe i didnt think of it. Just curious tho is that the only way to do it? what is the recomended way? all the books i have simply retrive values from forms. the only ones where they set values are for select menus.
  18. i get a error [quote]Parse error: syntax error, unexpected T_VARIABLE in /var/www/html/php/news_adder.php on line 32[/quote] heres line 32 [code]<input type="text" name="title" value="<?php$_POST['title_value'] ?>"/>[/code] also why do you have a "=" sign before the "$" sign when i do that i get a syntax error.
  19. Hi, i have a text box with a default value of null. There is a particular button i have that once you press it, it populates a select menu with data from a database. when a user selects a particular item in the select menu i wish to set the textbox value to "some string". i can use the $_POST array superglobal to to retrevie the information i need, but how do i set it ?
  20. well i succesfully implemted the time stamp thing, and i format it with th date() function for displaying it. ill definatly take at look in PDO thanks for the help. i was thinking tho its a unix style timestamp so the script wont work with windows
  21. [!--quoteo(post=380092:date=Jun 5 2006, 11:04 AM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Jun 5 2006, 11:04 AM) [snapback]380092[/snapback][/div][div class=\'quotemain\'][!--quotec--] You'll want to use TIMESTAMP then. Also, just on a side note. Have you looked into PDO? It is IMO much better than PEAR DB. [/quote] ok cool, i didnt even know there was a TIMESTAMP data type. Ill look into it. i have heard of PDO. its my understanding thats its pretty new. So with me being new my self to PHP programing i follow alot of books that talk about PEAR because PDO didnt exist at the time they were writen. so ill stick with it for now untill im comfortable with PHP in general
  22. [!--quoteo(post=380063:date=Jun 5 2006, 09:03 AM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Jun 5 2006, 09:03 AM) [snapback]380063[/snapback][/div][div class=\'quotemain\'][!--quotec--] Yes it will. Sqlite doesn't actually have any data types. Well it does, but they are all the same. So specifying a field as VARCHAR or TEXT is not really required either as internally its all the same. Strange little db that one. Very usefull though. But anyway... yeah, I prefer to create my dates using a unix timestamp. You can do this with the mktime() function. Then, to display them, I use the date() function to format them. [/quote] yes i understand you can put basicly anything in any datatype in sqlite. but i am using PEAR DB to comunicate with my database - so if i need to run my scripts on a diffrent server with say MySql, i should basicly only have to change one line of code. the line that connects to the actual database. so putting a unix timestamp is ok for the DATETIME datatype in most database software ? ill give it a try and see how i go.
  23. Hi first post :D I wrote a really simple script. its a script to print a News Topic and content to a web page. I store the news in a SQlite databse like so.. news_id INT news_topic as VARCHAR(100) news_content as TEXT date as DATETIME so far mt simple script can post the news topic and content fine, i use the news_id to sort it in DESC order so the latest news gets displayed first. i have the date coulm sitting there doing nothing at the moment. how would i go about puttin the date and time in there ? i know how to use PHP's date() function ok, but what format dose it have to be in ? will SQLite allow any date and time format to be put in there ? basicly how do you guys/girls reccomend i approch this ?
×
×
  • 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.