-
Posts
354 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Irate
-
You can use a for-loop for this. Possibly also dynamically compute the amount of pages you want to load before you use a hard-coded constant.
-
You can use regular expressions to filter user input. For example, you have the submit button for the textarea which has a name of, say, "newpost". You can just generally filter out HTML tags to only allow wysiwyg tags (BBCode, to be exact) with regular expressions. An example below. $post = isset($_POST["newpost"])&&!empty($_POST["newpost"])?$_POST["newpost"]:""; if($post) { $post = preg_replace("#<(.*?)>#gm",""); # modify the string further now }You can also a predefined editor for this, such as the SCEditor (being used by a free forum host which I frequently use) or others.
-
Need help displaying variables through functions
Irate replied to eldan88's topic in PHP Coding Help
What AbraCadaver posted is quite a good example. compact() is quite what you want. Check the official document of compact() and then think how to use the script again. AbraCadaver possibly covered it all, just pointing out what he did. -
Warning: reset() expects parameter 1 to be array, null given H
Irate replied to coolapps's topic in PHP Coding Help
Check the code, you are creating a variable named $arr1, and then you reset $arr1u, not $arr1. Edit: bolded the u -
It is frowned upon to steal from other sites... But, anyway, your best guess is PHP - $othersite = file_get_contents("http://someurl.com"); would copy the contents of the source code into the variable $othersite. If you cannot use PHP, use document.documentElement.innerHTML.toString() in JavaScript, that'd give you the entire head and body content of the site, though you'd might need to check for any attributes on the documentElement if they are relevant to the site flow (like, if its dir attribute it rtl and not ltr, or the lang is something other than en). Once again, stealing stuff from other sites is frowned upon. Don't do it. Examples above are just for documentation purpose, I do not condone any misconduct...
-
Try using something like this... $.fn.req = $.fn.jquery.indexOf("1.3.") > -1 ? $.fn.click : ($fn.jquery.substr($.fn.jquery.indexOf("1.4."),$.fn.jquery.lastIndexOf(".")) >= "1.4" ? $.fn.dblclick : $.fn.click);If the jQuery version is 1.3 (or any version of 1.3), the $.fn.req property will be the normal click method of the jQuery object, otherwise, if the version is 1.4 or higher, it will be the dblclick function.So, to write code with the .req property, you'd do something like this. $(function(){ $('#clicked_element').req(function(e){ alert(e + " was fired."); }); });By the way, $.fn is the jQuery prototype object.
-
I guess you are using XML for that, so why not use simplexml for PHP? It's quite a nice library with very handy methods and properties on your .xml file. If you want to call the string directly, why not use a <response attribute="your string" />? You can then call an eval($xmlfile->response{"attribute"}) (well, to be honest, I forgot the syntax for getting an attribute of an element... but look up the online documentation for simplexml) or whatever you need to do with the string.
-
Gmail has some SMTP solutions, you could try there. That'd of course require an internet connection, but so do the Linux distributions... well, generally everything with emails.
-
As someone with a high status here says in their signature... "Using global is a sign of doing it wrong." So, because this is necessary, where do you want to have $db defined? Everywhere in your class? Everywhere in PHP?
-
Try this... preg_match('#"key":"(.*?)"#',$content,$match); echo $match[1];
-
What does it echo right now?
-
Check your httpd.conf or your apache.conf file, find the line named "Listen" and change it to "Listen 1234", where you can change 1234 to whatever port you want. You must also then type in, if your line was 1234, "localhost:1234" or "127.0.0.1:1234" and then your file URL.
-
32603 profile views doesn't seem legit O_O
-
Try using JavaScript for that jQuery (a JavaScript framework) has some excellent modal dialog box support.
-
Try using JavaScript for that jQuery (a JavaScript framework) has some excellent modal dialog box support. Edit: to the moderators, I excuse for the double post :/ My mobile made itself self-concious and posted twice (no, I had to reset my connection and my mobile resent the data)
-
To add something to what Psycho said... Web Design nowadays is a lot more than just setting a few fonts, some fancy colors here and some nice padding, right now, with CSS 3, transitions are coming to enable previously static sites to be animated without using any scripting language (Flash (as in, ActionScript, too), JavaScript, Java) and they require quite a lot of skills, and it is definitely nothing to be looked down upon. Web Design can, just like Web Development, get you a nice and quite well-paid job, and it is nowhere near being bored during the job. However, Web Design also involves generally graphical skills (Photoshop, etc.) and, most importantly, a good imagination of how your ideal website would look like (unlike the Web Developer who cares for the actual functionality of the site). I cannot really speak about qualifications or any experience in jobs right now, though, as I am right now only getting ready to start searching for jobs myself. As Web Developer, you will certainly have a more "challenging" job experience (if you're not currently using CMS's, that is) due to the complicated nature of all programming languages for the unskilled eye. If that's what you like to do (I do, certainly), then go get yourself a nice degree. I'll do just that, possibly a general degree for Computer Science or something more specific like a qualification for online programming languages, though I believe my nearest university does not offer such course. Oh well. Help my post helped you out deciding a bit
-
Your files should be located in the htdocs folder, otherwise localhost won't respond to them.
-
How to find 2 or more words in a string with preg_match?
Irate replied to noidea's topic in Regex Help
@.josh: Hm, true that, but doesn't your code invoke preg_match at least twice, too? Anyway, yeah, point taken. I'm still learning the extensive parts of PHP, as in, query minimization, storage release and so on.- 13 replies
-
- preg_match
- search
-
(and 1 more)
Tagged with:
-
How to find 2 or more words in a string with preg_match?
Irate replied to noidea's topic in Regex Help
It would have worked with the code I gave you at the start, too, it just depends on how you need to work with it. Glad you found a fitting solution.- 13 replies
-
- preg_match
- search
-
(and 1 more)
Tagged with:
-
background:url(..); working fine in mozilla but not on chrome
Irate replied to ManpreetBajwa's topic in CSS Help
Try using background-image: url('/Living_Space_Construction_Logo.jpg'); - also, are you sure the image should be located in the root folder? -
Do you have Apache installed and can you access your .htaccess file? You can perform URL rewriting from there. Like this. RewriteEngine On RewriteRule ^/wp-content/uploads/(.*)$ /media/$1
-
Did you modify anything on your server recently? If the access such site, well... Try this. <?php foreach($_GET as $g) { if(preg_match("~[\da-zA-Z]+~i",$g)) { echo "Invalid request."; } } ?>
-
Are you sure you inserted it there? It seems a lot like some XSS attempt... you should immediately check your log for any suspicious activities...
-
That's the one thing you cannot hide unless you'd create your own browser and distribute it to every single internet user. Sadly, you are not a multi-billion company like Google to afford that (I guess, I highly doubt it), so the answer to that is no. There is no way to prevent the user from getting the link from SOMEWHERE out of your code, be it now the href attribute or some JavaScript-implemented redirect, the user would be able to figure it out. You could, if you are very eager for the user not to know where to redirect, try JavaScript code obsfuscation, but that's a pretty shameful thing to do unless you are actually trying to hide crucial data (and even then, you'd be doing it wrong - storing data with JavaScript is generally a bad idea and easily discovered).
-
How to find 2 or more words in a string with preg_match?
Irate replied to noidea's topic in Regex Help
preg functions accept a string as argument containing your regular expression, delimited by two of the same characters, like, as commonly used (since you need to escape the starting character if you want to match them directly in your regular expression) are "#", "~" or "/". What .josh's code did was to create an array with the search terms in it ("foo" and "bar" have a long tradition of being used as examples in the IT branch), then he loops through that same array, creates a regular expression out of them and matches them against the text to search through, and if those functions return false, the whole variable $allMatched becomes false and you know that the text did not include all the keywords the user searched for.- 13 replies
-
- preg_match
- search
-
(and 1 more)
Tagged with: