-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
You don't have any delimiters in your regex (the thing that tells pcre where the beginning and end of the pattern is, like /../). You should have gotten an error message from that, so maybe you have error reporting turned off. Other than that, it should have worked. Another way to write it is like so: echo preg_replace("/<[^>]*>/","",$string);
-
Unable to modify posts with google chrome.
.josh replied to blueman378's topic in PHPFreaks.com Website Feedback
so are we going to make threads and posts, every time a browser is bugged? And is everybody and they moms going to chime in and say they have the same problem? Geez, go post in the browser's support forum. What are we supposed to do about it? -
You would store the info in a session variable. Session variables persist from page to page.
-
There was no function in that spreadsheet, and as far as I can tell, there is no pattern to be made from those numbers, in which to create a function.
-
no, like what you have in your while loop: $title = fgets($f, 4000); while($line = fgets($f, 4000)) { ... }
-
$pph = round($pph, 2);
-
if it's the first line in the file, do an fgets 1 time before the while loop.
-
Hmm...tbh I think you should rethink your script structure in the first place, but whatever. My take: asort($array); foreach($array as $name => $num) { $count[$num]++; } foreach ($count as $c) { $t = array_splice($array,0,$c); ksort($t); $array = array_merge($array, $t); }
-
where are you getting the array keys from? Do they have to be the array keys? Could the names be array an element instead?
-
A Content Management System is just that: a system, made up of lots of code that does a million different things. It's not a single brick in a wall, or even the wall; it's a whole house. And it sounds like you're at the brick level. When it comes to advice or code, there is no quick and easy magic wand, unless that magic wand is called money and it's waved at someone else.
-
New here looks like an awesome site! Can someone help me with this?
.josh replied to edman78's topic in PHP Coding Help
As revraz stated, the idea is to cycle through the categories, which are no doubt stored in your database. It looks like $option_list is already a generated string of options, so there's already a query and a loop for that in your code somewhere. All you need to do is follow that example, except with checkboxes instead of option tags. Or if you were wanting to replace the dropdown with the checkboxes, just alter that code (also remove the select tags where the generated $option_list string is echoed, obviously). Thing is though, I'm not seeing anything in item.php where the option values are being assigned to $option_list, so you're going to have to look somewhere else. -
Getting logged off after 3 mins all the time.
.josh replied to phpSensei's topic in PHPFreaks.com Website Feedback
Is this the only site that happens for? -
shouldn't be a problem, unless you're trying to echo it with the double quotes; then it would be trying to interpret it as a variable. But I don't see any echoes up there. Perhaps if you were to be more specific than "it doesn't work"?
-
Inserting static html into a dynamic php script...
.josh replied to will_1990's topic in PHP Coding Help
Oh okay yeah that's right, because there are certain times when you're going to want to echo out those tags over and over again, like when you...I mean, like when...hmm..nope, I got nothin'. -
Inserting static html into a dynamic php script...
.josh replied to will_1990's topic in PHP Coding Help
I imagine putting the html, head and body tags inside that loop are going to cause problems on some level... -
Using a variable as a session variable's name?
.josh replied to psyickphuk's topic in PHP Coding Help
You're using the names correctly. The problem is that you're checking to see if it's set, and if it's not, you're setting it to null...that's about as useful as setting a variable to 1 if it's 1.... also you forgot the = in the array assignment $field_list = array("text1", "text2", "etc"); But I assume that was a typo... -
The one you said is causing 2 updates to happen... $template->assign_block_vars
-
So what does that method look like?
-
Okay well if you're going to try and make a number out of arbitrary stuff being entered in at arbitrary places (random money formats, letters, whatever....), why not just make a really simple. Just extract the numbers. Who cares where they are or what was used. We'll throw in a decimal match, since there is a difference between 100.00 and 1.0000. Then money_format it. preg_match_all("/\d|\./",$string, $match); setlocale(LC_MONETARY, 'en_US'); $num = money_format('%n', implode($match[0]));
-
(?:\<a.*href="([^"]*)"[^>]*>)[.\W]*(?:\<img.*src="([^"]*)"[^>]*>)
-
Okay let's back up a minute. Post several examples of what the actual string may look like. The way I understand it is, you have for examples: <a href='url'><img src='image'></a> <a href='url'><img src='image' width='1' height='1'></a> And so you are saying that you want to extract 'url' and 'image' right?
-
premiso: If you use global inside the function, variable's scope will extend outside the function. The whole point of static variables is that they are 'remembered' after function is executed, but retain the function scope. In addition, recursion is when something calls itself, which is not what you're doing in your solution. justinh: Just thought I'd point out that grammatically, putting (s) at the end of something makes it optional, so technically, you would have time(s) no matter how many times the function is called. In your if..else condition, you would want to display 'time' or 'times'; no parenthesis. Just a minor bitch from the grammar police. <?php function myfuction(){ static $a = 1; if ($a == 1) { echo "this function has been loaded " .$a. " time<br />"; } else { echo "this function has been loaded " .$a. " times<br />"; } $a++; } for($i = 0; $i <= 8; ++$i){ myfuction(); } ?>
-
<img.*src='([^']*)'[^>]*>
-
True that. I myself only started giving regex a serious effort about a month ago. It's scary and frustrating and addictive to all hell. And on that note... $var = "04 - blahblahblahblah - thisthatandtheother"; preg_match("/-\s(.*)/",$var,$match); echo $match[1]; That will work, even if your string were like 04 - blahblahblahblah - thisthatandtheother 04 - blahblahblahblah - thisthatandtheother - laksdklsdfj 04 - blahblahblahblah - thisthatandtheother - lksdfjklsjdf - lkasdfjlksfj - kasjdfljlj or hell, anything with an initial "- " - blkajsdlfkjslfskjdf - blkjasdflkj asdlkjfs laksjfdls - asldfkjasdf
-
die() will only work if there was a problem executing the query. If nothing was found in the db, it returns false, but that's not a failed execute. You need to wrap a condition around your unlink. something like this: <?php $file = $_GET["id"]; $delid = $_GET["delid"]; include "my_sql.php"; mysql_query ("DELETE FROM uploadedimg WHERE name = '$file' AND killcode = '$delid'")or die; ijf (mysql_affected_rows() > 0) { $myFile = "./images/$file"; unlink($myFile); } ?>