redbullmarky
Staff Alumni-
Posts
2,863 -
Joined
-
Last visited
Never
Everything posted by redbullmarky
-
[!--quoteo(post=357012:date=Mar 21 2006, 04:49 PM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Mar 21 2006, 04:49 PM) [snapback]357012[/snapback][/div][div class=\'quotemain\'][!--quotec--] [code] $john=10; // if john is more or equal to 10, this while loop wont execute. while($john<10) if($john==2){ echo $john; $john++; <-- means that john will only ever increment when its value is 2 } echo "<br> loop stoped at ".$john; ?> [/code] [/quote] forgive me if i'm missing something, but i can't actually see why the while loop would even start, never mind hang. you set $john to 10, then specify that the while loop only runs whilst $john is LESS than 10. but lets say for example that the while loop started, and $john started off at 0, like in the 'for' loop. the logic in your script would only ever cause $john to be incremented if $john reached 2. as $john starts off at 10 (or even if you started it from 0), this condition of $john being equal to 2 would never be met, $john's value would never be incremented, so $john would always be less than 10 so the while loop would go infinitely.
-
whilst it may not make much difference, the fact that you are getting no errors for Jpg's and you are for gif's indicates SOMETHING wrong with the file format. try making a simple gif file using mspaint or something other than photoshop. also, can you post your code that youre using to display image files?
-
[!--quoteo(post=356979:date=Mar 21 2006, 02:43 PM:name=AV1611)--][div class=\'quotetop\']QUOTE(AV1611 @ Mar 21 2006, 02:43 PM) [snapback]356979[/snapback][/div][div class=\'quotemain\'][!--quotec--] In your opinion, do I need to FIX or RECREATE the site? Thanks... [/quote] fix. the work is done - like your title says, it's just cosmetic updates as well as little fiddly bits that need attention.
-
[!--quoteo(post=356986:date=Mar 21 2006, 03:11 PM:name=wardo)--][div class=\'quotetop\']QUOTE(wardo @ Mar 21 2006, 03:11 PM) [snapback]356986[/snapback][/div][div class=\'quotemain\'][!--quotec--] I tried putting the path in and now it works :) I dont understand what it does though? Thanks for your help. [/quote] in it's simplest terms, it tells the cookie where it's available to. from the manual: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] If set to '/', the cookie will be available within the entire domain. If set to '/foo/', the cookie will only be available within the /foo/ directory and all sub-directories such as /foo/bar/ of domain. The default value is the current directory that the cookie is being set in. [/quote] me personally, i ALWAYS set it to '/' so my whole site can use it if necessary. Cheers
-
[!--quoteo(post=356981:date=Mar 21 2006, 02:58 PM:name=wardo)--][div class=\'quotetop\']QUOTE(wardo @ Mar 21 2006, 02:58 PM) [snapback]356981[/snapback][/div][div class=\'quotemain\'][!--quotec--] I've tried those things but it still wont work. when I set the cookie on the page that checks the login, and i check to see if the cookie has been set it works fine and shows me the cookie, but when i go to any other page, the cookie is not recognised. Why would the cookie not be available on other pages? [/quote] did you try setting the cookies expiry and path like i suggested?
-
you could do with using a few extra parameters in setcookie - one for the expiry date, and one for the path. this will make the cookie last for 30 days and allow any script within the domain to access it: [code] setcookie('policyusername', $username, time()+60*60*24*30, '/'); [/code] [b]EDIT[/b]: otherwise, make sure that $username has been set correctly before trying to save it as a cookie, and also note that cookies are only available when the page that first sets it has been reloaded or from other pages.
-
[!--quoteo(post=356924:date=Mar 21 2006, 12:24 PM:name=moberemk)--][div class=\'quotetop\']QUOTE(moberemk @ Mar 21 2006, 12:24 PM) [snapback]356924[/snapback][/div][div class=\'quotemain\'][!--quotec--] Thanks for clearing that up. I don't think I fully understood what this site was. Maybe you should have mentioned this is a study tool in the first post? [/quote] it shouldnt really make a difference to the feedback he's after whether it's a shopping site, study tool or a personal homepage. if it works and looks good, great. if it don't, not so great. i think it's starting to look alot better. i still think though that you could make the bottom container larger and the others smaller, just to bring it into view a bit better. this becomes most apparent on the homepage, where it runs off the page totally - all it does is creates a browser scroll bar AND a frame scroll bar, both of which need to be used to get things into view properly. you've freed up some space in your right hand box now, so i reckon you've got enough space to do this.
-
[!--quoteo(post=356960:date=Mar 21 2006, 01:44 PM:name=wolves)--][div class=\'quotetop\']QUOTE(wolves @ Mar 21 2006, 01:44 PM) [snapback]356960[/snapback][/div][div class=\'quotemain\'][!--quotec--] I can be the last char of the memory? I don't know if preg_math serachs at the memory... what char is the last of a string in the memory? [/quote] i'm honestly not sure. there's a special character used to match any whitespace character, regardless. if someone else can tell you what it is, that'll be what you need.
-
[!--quoteo(post=356952:date=Mar 21 2006, 01:27 PM:name=wolves)--][div class=\'quotetop\']QUOTE(wolves @ Mar 21 2006, 01:27 PM) [snapback]356952[/snapback][/div][div class=\'quotemain\'][!--quotec--] humn, I think I understood; but how to match only if the year have to digits only? [/quote] hmmm someone else will need to help on this one, but you basically need to test for an end character (such as a space, new line, etc. can't quite remember what the character is. something like: [code] $match = preg_match('/[0-9]{2}\/[0-9]{2}\/[0-9]{2}[\ \n\r]/', '01/01/2005', $matches); [/code] may work but i'm sure there's a better way to check for the end of line. either way, you just have to check for a non-numerical character DIRECTLY after your year. [b]EDIT:[/b] the bit i added is [\ \n\r] - the 'space' does not appear clearly in my code snippet.
-
yes but it IS true. preg_match will use your pattern to find something ANYWHERE within a give string. so your match is actually matching correctly, and ignoring the 05 bit of your '2005' and matching with '01/01/20' which fits your criteria. you could put 2000000532 as the year, and it'd still come back true. try it: [code] echo 'matching 01/01/2005:<br>'; $match = preg_match('/[0-9]{2}\/[0-9]{2}\/[0-9]{2}/', '01/01/2005', $matches); print_r($matches); echo '<br><br>Matching 01/01/12547612345:<br>'; $match = preg_match('/[0-9]{2}\/[0-9]{2}\/[0-9]{2}/', '01/01/12547612345', $matches); print_r($matches); [/code] both of which will come back true. the first will show '01/01/20' as a match, the second will show '01/01/12' as a match. Cheers
-
[!--quoteo(post=356939:date=Mar 21 2006, 01:00 PM:name=wolves)--][div class=\'quotetop\']QUOTE(wolves @ Mar 21 2006, 01:00 PM) [snapback]356939[/snapback][/div][div class=\'quotemain\'][!--quotec--] I'm trying to use, preg_match to find a string like this '01/01/05' so I'm using preg_match('/[0-9]{2}\/[0-9]{2}\/[0-9]{2}/', '01/01/05' ); but If I pass '01/01/2005' preg math returns true :( [/quote] that's because it's actually finding exactly what youre after, regardless of what's contained each side of it. when you run the above preg_match, what it sees/finds is: 01/01/20 , which actually meets the criteria you've set it. all you can really do is test for whitespace after the date (or an end of line) or just validate the results when you have them to make sure that the date was entered in 2digit year format. Cheers Mark
-
modified from an example on php.net/imagefilledellipse. you'll need to change it again to suit your needs: [code] // break up color into its RGB parts $color = $_GET['color']; $r = hexdec(substr($color,0,2)); $g = hexdec(substr($color,2,2)); $b = hexdec(substr($color,4,2)); // fill the background color white $bg = imagecolorallocate($image, 255, 255, 255); // choose a color for the ellipse $col_ellipse = imagecolorallocate($image, $r, $g, $b); // draw the ellipse imagefilledellipse($image, 200, 150, 300, 200, $col_ellipse); [/code] hope that helps. i've not tested it but should work or set you on your way... Cheers Mark
-
Parse error: parse error, unexpected $
redbullmarky replied to lpxxfaintxx's topic in PHP Coding Help
you have two problems, both in the same block. you need to treat array values differently to normal variables when putting them in double quotes (use curly braces {}), and you also need a closing bracket for your while loop. so: [code] while ($row = mysql_fetch_array($result, MYSQL_NUM)) { echo "<option value='{$row[0]}'>{$row[1]}</option>"; <-- curly braces } <--- you forgot this ?> [/code] that should do you Cheers -
[!--quoteo(post=356914:date=Mar 21 2006, 11:56 AM:name=eranwein)--][div class=\'quotetop\']QUOTE(eranwein @ Mar 21 2006, 11:56 AM) [snapback]356914[/snapback][/div][div class=\'quotemain\'][!--quotec--] the missing ; is not relavent because it's not copy+paste from the code. how do io set my error reporting to display my problam? [/quote] a few ways. change your php.ini file directly, use a .htaccess file, or at the top of your scripts put: [code] error_reporting(2039); ini_set("display_errors","on"); ini_set("display_startup_errors","on"); [/code] for some reason when i do it this way, if the script has a major error it doesnt seem to tell me. so i'd recommend making a text file in your root called .htaccess, and putting the lines: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] php_flag display_errors on php_value error_reporting 2039 [/quote] in it. this will show you all the important stuff and should let you know exactly what your problem is cheers
-
uploading files is done in binary, so the language within the file wont make a difference to anything. my guess is that you've got an error, but have error_reporting too low or display_errors set to off in your php.ini file, so you arent seeing the problem. but you have a missing ; at the end of your line: [code] if (move_uploaded_file($_FILES['uploadedFile']['tmp_name'],$file_path)) print "file insert"; <--- here else print "file not insert"; [/code]
-
pretty much, yes. if they have further problems, then a line like: [code] ini_set("SMTP", "smtp.celebcars.co.uk"); [/code] or whatever their outgoing mailserver is next to the other ini_set line should also help.
-
I couldn't get the link you provided to work, but the code in question, ini_set, would go before the 'mail' function is called. i normally stick things like that right at the top of my page, after my includes and session_start(). the mail function's manual, ( [a href=\"http://uk.php.net/mail\" target=\"_blank\"]http://uk.php.net/mail[/a] ) will probably shed some light on what you want youre tryign to achieve, but when i change servers, normally the only setting i need to alter is 'SMTP' if i havent got a mail server set up on the same server as the php. otherwise, i can't really see many reasons why the code you've posted still wouldnt work as it is. did they give you any info in terms of the problem they were having?
-
[!--quoteo(post=356895:date=Mar 21 2006, 09:06 AM:name=amlegypt)--][div class=\'quotetop\']QUOTE(amlegypt @ Mar 21 2006, 09:06 AM) 356895[/snapback][/div][div class=\'quotemain\'][!--quotec--] I have made alot of change - [a href=\"http://www.amlegypt.com\" target=\"_blank\"]http://www.amlegypt.com[/a] shows your forum, with no (apparent) links to the main site. - [a href=\"http://www.amlegypt.com/board/index.php\" target=\"_blank\"]http://www.amlegypt.com/board/index.php[/a] shows your main site. shouldnt these two be the other way around? as previously stated, your forums are very plain and really have nothing to critique. as for your site: it looks ok, if a little bright. orange and light green on while background can be a bit mad on the eyes after a while. i notice at the bottom it says 'powered by enome'. is this a pre-installed script or did you code it all yourself?
-
*SOLVED, I think* Code tags
redbullmarky replied to Barand's topic in PHPFreaks.com Website Feedback
[!--quoteo(post=356865:date=Mar 21 2006, 05:23 AM:name=AV1611)--][div class=\'quotetop\']QUOTE(AV1611 @ Mar 21 2006, 05:23 AM) 356865[/snapback][/div][div class=\'quotemain\'][!--quotec--] Well, as of the time of this post, it's still not working... I have a post I've been trying to post to help someone for a day and a half... and it had freads/writes, etc.. in it... i've noticed a few things recently. yes it seems to be the fopen, fgets, etc that are causing the problems. also i keep getting errors on firefox relating to the script having an error when loading the main phpfreaks forum page. a coding site with errors is also a little offputting, but seems like it's since alot of these ajax tooltips were introduced that things seem to have gone a bit pear shaped. -
you're on the right track. now you just need to compare the date with the range. [code] $special_date = "2006-05-28"; $start_date="2006-05-20"; $end_date="2006-05-29"; $start = strtotime("$start_date"); $end = strtotime("$end_date"); $special = strtotime($special_date); if ($special>=$start && $special<=$end) { echo 'thats a special date!'; } [/code] cheers Mark
-
Useing An Image As A Link Then If statement for that image
redbullmarky replied to skatermike21988's topic in PHP Coding Help
[!--quoteo(post=356869:date=Mar 21 2006, 06:09 AM:name=Skater Mike)--][div class=\'quotetop\']QUOTE(Skater Mike @ Mar 21 2006, 06:09 AM) [snapback]356869[/snapback][/div][div class=\'quotemain\'][!--quotec--] Any Help Anyone? [/quote] you could make a link from the image which re-calls the page with a URL parameter that, when detected, shows the relevent details, using $_GET or you could preload the info within a hidden table/div tag and use javascript to reveal it when the image is clicked. -
[!--quoteo(post=356872:date=Mar 21 2006, 06:24 AM:name=eranwein)--][div class=\'quotetop\']QUOTE(eranwein @ Mar 21 2006, 06:24 AM) [snapback]356872[/snapback][/div][div class=\'quotemain\'][!--quotec--] i need to check if an uploaded file exists. i'm using file_exists($filename). as i understand, the $filename should be the path and name of the uploaded file. $_FILES['uploadedFile']['name'] returns only the name but not the path. so how do i do it? [/quote] the file is uploaded to $_FILES['uploadedFile']['tmp_name']. best thing to do then is to use is_uploaded_file, such as: [code] if (is_uploaded_file($_FILES['uploadedFile']['tmp_name'])) { ... we got the file, use move_uploaded_file to put it in a proper home } else { .... we not got the file } [/code] hope that helps
-
unenergizer, thanks for your help. you've made me think a little harder and come up with a few solutions, anyway. for the benefit of anyone that's interested, these are the ways i've got working or partially working, both off my own bat and from suggestions here: 1, ftp. their ftp credentials are programmed into their database and when an update is required are posted to my server (without me being able to get access to them) to check for the files needed. my scripts on my server interract with their server and give them the required files. this appeared to be the best method. however, because of a few reasons (i'm stubborn, wanted to stretch my knowledge a bit, was determined to do it without passwords, etc) i have come up with this: 2, on my server, i have a file which prepares a file ready to send. literally by sending the php file to the browser in it's actual state, without the server parsing it first. this done with fopen, fgets, echo (i'd post the code, but for some reason phpfreaks doesn't like it, with or without the [CODE] tag. either way, the script on their server is almost identical, using fopen to read this file, and saves a local copy on their server. 3, mysql. possibly the most likely way i'll end up going with, if i can set up a remote connection from their site. but if they can connect to my 'updates' database from their site, then they can literally download the required files, which will be stored as BLOB type (it would be TEXT, but sometimes the files will be images and other filetypes, etc). their server sends a request to mine for the latest login credentials, which mine responds back with. their server uses these to access the updates database, downlaods the relevent file, and then puts it in the correct place. obviously my biggest fear is that of security, but i think that i can make either of these 3 quite watertight as i would with a login/membership system. if anyone has any thoughts on any of these, or could elaborate on why/why not to use any of them, then please feel free to comment. Cheers Mark
-
actually this maybe right also. i just remember i have a plugin on firefox called 'Reveal' which, when you hover over the browsers back or forward button, shows a thumbnail preview. size of the thumbnail can be adjusted, etc.
-
[!--quoteo(post=356873:date=Mar 21 2006, 06:28 AM:name=Skater Mike)--][div class=\'quotetop\']QUOTE(Skater Mike @ Mar 21 2006, 06:28 AM) [snapback]356873[/snapback][/div][div class=\'quotemain\'][!--quotec--] ok i am working on a new members thing on my page and i want users to be able to upload an image to my site and the directory be stored in the database so i can do something like this <img src='$image'> Now How Would I Do This So It Uploads It and Then Pulls It From The Databse To Be Displayed? [/quote] without literally going through the entire code, there are 3 things to deal with. first is to set up the <FORM> with the necessary elements: [code] <form action="" method="post" enctype="multipart/form-data" name="form1"> ...stuff here <input name="imagefile" type="file" id="my_image_file"> ...more stuff here including a submit button [/code] once the form is submitted, the file is automatically uploaded to the servers temporary directory. to deal with it from their, you need to use the $_FILES superglobal array to get the info you need about the file, and move_uploaded_file to move the file from its temporary location to where you want it to be permanently [code] $result = move_uploaded_file($_FILES['my_image_file']['tmp_name'], $newfilepath); [/code] all you need to do then is use some of the info from the $_FILES['my_image_file'] array to store info in the database for later. - the file size, $_FILES['my_image_file']['size'] - the file type, $_FILES['my_image_file']['type'] - the original file name, $_FILES['my_image_file']['name'] and for error trapping, use $_FILES['my_image_file']['error'] in terms of database retrieval, you just pull the filename from the database and put it within the IMG's src. hope that helps.