-
Posts
5,717 -
Joined
-
Last visited
-
Days Won
6
Everything posted by Adam
-
I don't want to test the limits myself, but are you aware Google requests Captcha verification if you spam it? Being behind a proxy we sometimes get it at work..
-
Just starting out.. How much should I charge for a PHP web applications site?
Adam replied to sandpc's topic in Miscellaneous
I don't think you should base your prices on what some of the freelancers here would charge. As you said, you're learning as you go which puts you in a different position. Does the client know that, as current, you aren't able to do what you're saying you will do? -
The problem is you're blindly trying to return rows from a MySQLi result resource, that isn't actually a result resource -- i.e. the query has an error. $r = @mysqli_query ($dbc,$q); mysqli_query() never actually throws a PHP error, so there's no use in the "@" to suppress errors. However you should handle the error here and throw one yourself: $r = mysqli_query($dbc, $q) or trigger_error('MySQLi Error: ' . mysqli_error()); That will tell you why the query is failing. Obviously you'll fix any errors before pushing to a production server (where display_errors should be turned off anyway), so it should never throw an error the user will see.
-
No worries. Unusual use of a closure by the way, did you write that yourself?
-
JavaScript Not Working on Localhost Wordpress Installation
Adam replied to chaseman's topic in Javascript Help
Do you receive any JS errors as you try? There should be an error console for your browser (for FF you can press Ctrl+Shift+J). -
It works for me without the alert. What browser are you testing with?
-
Ha.. right click and view the source, then copy from there. That will preserve the formatting..
-
Could you post it again within tags?
-
If you have lots of functions requiring the same data - and so presumably are related in what they do - you should consider an object-orientated approach. That way you need only pass it to the constructor method, and you can have it available throughout the object.
-
I'd guess that there are no children nodes of $post, so the children() method doesn't return an object. Use var_dump to view what $post contains, and post here if you're unsure.
-
Yeah, and I think the 'junk' values are just what it will be using as it tests the forms - doesn't necessarily mean it's open to SQL injections.
-
No include or require statement REQUIRES an absolute path. Also, you can't add get parameters to an include file like you showed. Parameters like that are a part of the HTTP protocol, which isn't used when including internal files. Any GET parameters that are passed to the originally requested file are available within the included file too. So if you request "foo.php?str=Hello", then include a file, $_GET['str'] is available within the included file too. So are normal variables you define within the parent file.
-
You could tarball the files you need to upload first, and then extract them in place. That would cut out the transfer rate issues. Although you should really perform roll-outs late at night, or when usage is at it's lowest to prevent issues like this. If that's not possible, then you should consider putting the site into 'down for maintenance' state, with permits access for yourself, so that you can test the updates are okay and you don't need to roll-back the files.
-
What's the problem with it?
-
Yeah, pass the data into whatever class or function it's needed as a parameter.
-
Okay - I assume you use a relative path to include this file originally? I would decide whether you actually need any complex logic to include files - is your file structure that complex you can't just use simple relative paths to include everything? If so.. In PHP you can configure the 'include path' used by the include/require control statements. You can also set multiple include paths it will use to attempt to include the file, in the order they're stored. By default these are generally the current directory, followed by the root directory of your website - though this may not be the case on a development server you've set-up yourself, in which case it's generally the document root. Better than creating a variable, that you would have to add to all your includes, would be to configure this include path so that it automatically checks a certain directory so that you don't need to add anything manually. If the path of all your PHP files that you want to include is the same as your config file, you can use this code: set_include_path( get_include_path() . PATH_SEPARATOR . dirname(__FILE__) ); That will set the include path as the already set include path, but amend it with the directory name (and path) of the special __FILE__ constant, which stores the file path of the current executing file. As I said that will only work if the PHP files you wish to include are within the same, or sub-directories of, the directory in which the config file is. If that's not the case you can add a relative path, based on the config file's directory, to set it to what you want. For example, assume you have the following file structure (config is separate from the PHP purposefully): You would want to set the include path as the "php/" directory, however you always run the config file from "config/" - it's a bit of a stupid set-up in that regard, but it's just as an example. In that case you could use the following code: $include_path = dirname(__FILE__); $include_path = realpath($include_path . '../php'); set_include_path( get_include_path() . PATH_SEPARATOR . $include_path ); That does almost the same as before, except adds in an extra part which makes use of realpath - which can return the absolute path for any relative path you give it. In this case we add the relative path to the PHP directory from the config file, which will give us our absolute path. So whichever way you set the include path, now you should be able to just include files from any location like: include 'file-i-want-to-include.php'; Don't be put off by how much I've ranted about this, it's extremely simple once you know what you're on about.
-
Removed? In the code you posted before there wasn't a closing bracket after the foreach expression..? Should be: foreach ($errors as $msg) {
-
No, the URL path refers to "http://example.com/..." It's the public - "document" - root from where users can request files. The server path is the internal path, like for example on a *nix machine it could be "/var/www/example.com/...", or on Windows "C:\Program Files\Apache\www\example.com\..." or something along those lines. Absolute just means from the root , the base, point of the path. A relative URL/path means from the current location.. I.e. "../path" means go up a directory, and "./path" means from the current directory. Using those you can set the path to any point on the server, but it's from a relative position. Edit Sorry to actually answer your question, you can set the include path PHP uses to include files. What's the structure like of your files? Do you have a config or header type file you include to set the $site_url variable you mentioned?
-
error_reporting() should still be enabled, albeit at a much higher level (fatal errors only), so that the server's error log still gets them. That way if users start reporting issues with the site, you can show them a "Sorry we're having technical difficulties" type error, but then look-up the actual error in the log. Best scenario would be also to get an email when ever a fatal error is triggered. Of course you don't want this on DEV, you just want all errors displayed instantly.
-
Use the server's absolute path, not the URL.
-
The PHP fatal error will still be shown..
-
In a development environment you want those errors, so that you can spot them instantly and fix them. On a production environment however, you should have all error messages disabled anyway. If possible this should be set within the server's php.ini configuration file, but if not you can set it from within the code: ini_set('display_errors', 0);
-
You're missing a closing bracket in your foreach loop: foreach ($errors as $msg {
-
You could just use PuTTY to access the server's VI(M?) editor (assuming it's Linux). That's real easy to transport, heck it's even available as an iPhone app now!
-
If he's only touched the basics of programming (in whatever language) how would ever know to type in 'process instantiation' or anything of the sort? It's not even so much what you say just way you blurt it out like you've changed his life or something.