-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
echo $matches[1][0]; // echo out id of 1st thread echo $matches[1][1]; // echo out id of 2nd thread echo $matches[1][2]; // echo out id of 3nd thread // etc... echo $matches[2][0]; // echo out title of 1st thread echo $matches[2][1]; // echo out title of 2nd thread echo $matches[2][2]; // echo out title of 3nd thread // etc... If that's too much for you, you can do something like this: $ids = $matches[1]; // your id array is now $ids so you can do for ex: $ids[1] for the 2nd id $titles = $matches[2]; // your title array is now $titles so you can do for ex: $titles[1] for 2nd title
-
Actually, didn't see that you also wanted thread names. // example board $board = file_get_contents('http://forum.tibia.com/forum/?action=board&boardid=8527'); preg_match_all('~threadid=(\d+?)"[^>]*>([^<]*)<~',$board, $matches); echo "<pre>"; print_r($matches[1]); // <-- array of thread id's print_r($matches[2]); // <-- array of thread names Added bonus: this will NOT match the ids from each page number. edit: changed the first capture to be non-greedy to make it more efficient
-
// example board. $board = file_get_contents('http://forum.tibia.com/forum/?action=board&boardid=8527'); preg_match_all('~threadid=(\d+)~',$board, $matches); echo "<pre>"; print_r($matches[1]); this will list all of the thread ids on the page. Note however that since each page number is a link with the same thread id, you're going to have an element with the same id for every page number in the thread that is listed on the page. If you don't want that, look into array_unique
-
doing it with a 'key' like that still gives users opportunity to gain access. Put it outside of your web root, problem solved.
-
Up all night, still can't limit file types on upload
.josh replied to Reaper0167's topic in PHP Coding Help
one way... $allowed = array('.jpg','.gif','.bmp'); $fileName = $_FILES[$fieldName]['name']; $imageType = strtolower(substr($fileName,-4)); if (!in_array($imageType,$allowed)) { // file not allowed, do something } You could alternatively have an $allowed array of the different values in $_FILES[filename][type] -
$filename = 'path/to/filename'; $list = file($filename); // line in question is line 2 of file, so do replace on 2nd array element $list[1] = str_replace(....); file_put_contents($filename, $list);
-
List of board ids from that link: $Site = file_get_contents('http://forum.tibia.com/forum/?subtopic=worldboards'); preg_match_all('~boardid=([^"]*)"~',$Site, $matches); echo "<pre>"; print_r($matches[1]);
-
It depends on what your file looks like, as to how you would get the string to str_replace. Post an example of the file contents.
-
I'm not an expert at JavaScript either, but I'll look at it. In the mean time, I'll move it to the js forum. Maybe someone will know right off the bat, there.
-
Yeah, since you said that the code is all procedural, it really shouldn't be a problem. PHP5 was mostly all about new OOP features. If you follow the link PFM gave, you will find what is backwards incompatible. I have no idea what your scripts look like or what they do or anything, but looking at that link, most everything on there is a pretty easy thing to fix.
-
The only thing significant that php5 gets rid of is register globals. Basically that means for instance, if you have a form and a text input field named 'foobar', with register_globals on, you can access it simply by using $foobar, instead of through the $_POST or $_REQUEST array. With register_globals off (or removed), you would have to access it from $_POST['foobar'] or $_REQUEST['foobar']. Same thing with variables coming from the url string (the GET method) from links or via form GET method. Instead of being able to use $foobar you would have to use $_GET['foobar'] or $_REQUEST['foobar']. PHP4 already has register globals off by default, so chances are, you aren't even using them. So unless your script is making use of register globals, you shouldn't really need to change anything. php5 mostly just fixed some bugs and added a bunch of new features. A lot of things have been deprecated though...meaning they will still work, but they have been flagged for eventual removal (some things even as early as php6), so going from php4 or php5 to php6 might be more problematic for you. edit: hmm...I guess I must have read something wrong at some point in time...looks like register globals are still around in php5 and still disabled by default. They are being removed in php6.
-
PHP Warning: mysql_close(): no MySQL-Link resource supplied
.josh replied to camdenite's topic in PHP Coding Help
Unless you plan on using/managing multiple database connections, you don't even need to have that in there. the script will automatically close any connections when it's done executing. -
$string = preg_replace("~(http://|www\.)~","", $string); might be faster to use two str_replaces though: $remove = array('http://','www.'); foreach($remove as $r) { $string = str_replace($r,'',$string); } You can benchmark it yourself if you really want to know.
-
fyi: you don't need to state that something is copyrighted for it to be copyrighted. What a lot of people do is have a link to a copyright notice page/file. Could be your own custom license agreement or point to an existing one that lots of people use. Just depends on how strict you want your stuff to be copyrighted. Ideally, comments in your html shouldn't affect your site's SEO.
-
I don't think you're going to find a single tutorial that covers all of that, but you can break it down into individual components and find tutorials all over the place. For instance, you can search for a guestbook tutorial or blog tutorial for the actual content and comments. A 'rate this' tutorial for rating content/comments. Login or membership system tutorials for having registered users, etc... There are a lot of content management systems (CMS) out there that already have quite a bit of those features, if you want to go that route. Wordpress, Joomla, etc... a lot of CMS out there have a large community base that makes mods/addons for them, so you may even be able to find a mod/addon for even the features that don't come with the core CMS package.
-
Wow...even without the m tags you were putting too much work into it. You can just type http://www.php.net/functionnamehere and php.net will automatically take you to the page of the function. That is actually exactly what the m tag does. It just takes for example this: [m]echo[/m] and turns it into this: <a href='http://www.php.net/echo'>echo()</a>
-
wrap it in parenthesis. (date > NOW() OR date = '0000:00:00')
-
Ah, gotcha. Problem was with your quotes. It wasn't parsing variable because the quotes was confusing php. Just so you know in the future, php will parse variables inside double quotes, but it sometimes gets confused when handling arrays and properties and arrays within properties, etc... you could have also done this: body .= "{$p->ipn_data['element']}"; The brackets tells php where the start and end of the variable is, so it knows what to parse as a variable.
-
Okay so you have a hidden field for every single day of the month. How about instead of having your onsubmit toggle the value, you have it create/destroy the field? That way, only the ones that are 'highlighted' will have hidden fields, and only those will be sent?
-
LoL I feel for you. Got to start somewhere. No worries. p.s.- My suggestion about the null or zeroed date field isn't necessarily better than this. Technically it's better, because then you won't have to worry about having to change your script when Jan 1st, 3000 becomes a date things are being set for, but 1000 years in the future is a pretty long time, lol.
-
If you find yourself saying that then you probably need to sit down and re-think your database/table scheme/structure.
-
If you're not getting an error from move_uploaded_file then it should be uploading....somewhere. You have your target path/to/file set to: $target = "assets/images/gallery/" . $_FILES['uploaded']['name'] ; you sure you are looking in the right directory?
-
It depends on how you have your form setup. In order for values to be passed to the server, you have to name the element with the name attribute. The server doesn't care about the id attribute; that's a clientside thing. If your cells are not form elements, you will need to use javascript to grab the id of the flagged cells and put it in a variable (array would be better, since you're wanting to have multiple values) that can be posted. You'd have to use for instance onsubmit and call a function or something. I can't really be more specific than that without seeing actual code.
-
Are you using $p->ipn_data or $p->data or $_POST or what? I see all kinds of variables being used in your foreach loops your posting. Whatever you are using, I don't know how deep the arrays go before you get to your actual data. do echo "<pre>"; print_r($p->data); echo "</pre>"; and post what it echoes.
-
You should try to keep your data filtering inside your query. That is, after all, what databases are for. They are specifically built to store and optimally retrieve/filter data. If you want to select all dates not past yet, but also have open-ended 'events' that have no dates, you need to tell us how those 'open-ended' dates are being stored. What value is in the date field? Is it 'null'? 0? 0000-00-00? You have to tell us what it looks like in your database. The query is easy enough: ... WHERE datecolumn > NOW() OR datecolumn = null <--- insert the value of the open-ended dates here