-
Posts
5,717 -
Joined
-
Last visited
-
Days Won
6
Everything posted by Adam
-
Regular expressions are meant for complex string matching, this is basic: if (strpos('nprezident', $ex) !== false || strpos('prezident', $ex) !== false) { It's arguably a little longer to write, but there's no need to use regular expressions for something so simple.
-
Very elegant solution, mjdamato. @asurfaceinbetween You can also insert a new article at a specific position by updating all articles >= to that position, as position = position + 1.. update articles set position = position + 1 where position >= {$new_article_position} Then you just need to insert your article at that position as normal. A similar method can be used for deleting an article, except you just need to reverse the logic.
-
There's no point passing back a referenced variable, because any changes you made locally were done to the original -- the function's local variable is only a reference to the original variable. Something as small as the example you provided has no worth while benefit really, but consider and example where you're working with a large set of data that you need to pass between several functions; passing the data normally would create a new copy of the data for every function you pass it to, then you'd also have to return it and update the original. That can be a large over head given the size of some data (don't know if you've ever had the pleasure of working with BLOBs and CLOBs?), however if you'd referenced it when you passed it instead you'd only have the array in memory once (and several references pointing to it). Of course there's other uses for references not relating to memory, but so long as you understand the concept of them, the benefits will become clear one day when you find yourself in a situation they'd actually be useful for. Just don't include them for the sake of using them..
-
What were you searching with? It's the first result on Google for "php zip", and entering "zip" into PHP.net's search you're taken straight to it.
-
Can you provide a var_dump() of $form['catcher_id'] so that we know what you're working with? Could you also explain what you want to do and what's not working?
-
First I'd identify which version of Firefox is causing the problem, which OS they were using, etc. Try to find the common variable between those users, then try to recreate the error. You can't fix something when you don't know the cause of the problem.
-
You may want to come up with a more meaningful name for it, but try this function: function removeDecimalAndToSixPlaces($x) { list($number, $decimal) = explode('.', $x); $decimal = substr($decimal, 0, 6); if (empty($number)) { return (int) $decimal; } return (int) $number . $decimal; } echo removeDecimalAndToSixPlaces(52.71666666); //52716666 echo removeDecimalAndToSixPlaces(0.926888888); //926888 There's nothing particular complex within this, so you shouldn't have any performance problems runnning it 100,000 times. Although if this isn't something you plan on re-using, you should take it out of the function wrapper. sbustr couldn't be avoided as numer_format will round up the removed decimal points.
-
Generally just being able to read/write to one of those formats can be a complex task with PHP, never-mind reading from one and writing to the other. Most likely the reason you can't find anything on Google is because nobody has done it - or at least willing to release the code for free.
-
You were right with your second thought.
-
echo htmlentities($word);
-
I can't see the video at the moment as I'm at work connecting through a proxy, but when it comes to a website critique a video can look fantastic. Whether or not the website lives up to that in terms of mark-up, cross-browser compatibility, accessibility, etc. is another matter. If you want a proper critique, open up a private BETA site or something that we access.
-
onSubmit="return validateForm(newcat);" Here you're trying to pass a variable called "newcat" that doesn't exist. To pass a string you'd need to have quotes around it: onSubmit="return validateForm('newcat');" However it's easier to pass a special variable called "this", which represents the element's object, and use that within the function. So intead of calling document.newcat.category.selectedIndex for example, you'd use newcat.category.selectedIndex.
-
What data type are you using for the date column? You shouldn't need to use PHP to generate the date, MySQL has a built-in function called curdate() which will do that for you.. select * from table_name where date_column < curdate()
-
Floatbox and other javascript box functionality
Adam replied to brianlange's topic in Javascript Help
Never used it, but not keen on that floatbox. I prefer Facebox. -
First, what's the problem with it?
-
Assuming that SQL works as you want, try this: $sql = "SELECT INCIDENT_NO, SCHEME_CODE FROM incidents WHERE JOB_DATE_TIME LIKE '$searchDate' ORDER BY SCHEME_CODE, INCIDENT_NO ASC"; $query = mysql_query($sql) or trigger_error('MySQL Error: ' . mysql_error()); $prev_code = ''; while ($row = mysql_fetch_assoc($query)) { if ($prev_code != $row['SCHEME_CODE']) { $prev_code = $row['SCHEME_CODE']; echo '<br />' . $prev_code . '<br />'; } echo $row['INCIDENT_NO'] . '<br />'; } @unlishema.wolf It's double-equals. Also mysql_query only returns a result resource, you then have to loop through that using one of the fetch functions (e.g. mysql_fetch_assoc).
-
Oh.. So you are running the script from a local web server. Unless you have access to the server to execute FTP commands from it, then you'll need to use your local machine to get the files, before putting them to the other server.. unfortunately. You can use the temp directory as you say though, and just unlink them once you're done.
-
Well then on the server that the PHP script is executed, just ftp_put the files to the other server..? No need to go through your local computer.
-
I'm a little confused. Will you be running the script from your "local drive" with a web server installed? By server I assumed you meant you had an external web server you were running the script from.
-
You mean backslash, not "single slash"? Just looked back at your post and realized you were using a forward-slash.
-
Escaping the backslash will look for the literal "\n", not the newline character. It's possible the string has DOS/Windows carriage return characters ("\r") in it as well. Try this: $text = str_replace(array("\n", "\r"), '', $text);
-
Have you looked into the PHP FTP functions?
-
What are you wanting a critique on exactly? The design and functionality as you say are incomplete. I've seen several posts about this ASF forum before, and it seems a waste of people's time to keep requesting critiques on something you're only going to scrap and restart again in a couple of months. Perhaps wait until you're at some form of alpha/beta release before you request a critique?
-
Trying to understand your logic here. Could you provide some sample data and expected results to make things a little easier?