wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
put localhost in the first two boxes then for the email use a fake address, like admin@localhost.
-
Just download WAMP
-
Apache can comes in a Windows installer package (.msi) for installation on Windows. It can be Found here.
-
GET is the same as POST. Except GET is seen as its carried in the address bar. If a file name is followed by a question mark then anything after that is considered as a query string. A query string holds a collection of variables. A variable is set in the following format: file.php?var1=value1 So in the above example a variable is being set (var1) with a value (value1). To have more than one variable you'll separate them with an ampersand (&) eg: file.php?var1=value1&var2=value2 In order to get the variables from the query string in file.php you'd use $_GET. So to get var1 you'd use $_GET['var1'], for var2 you'd use $_GET['var2'] So if you ran the following script with the following url: file.php?var1=value1&var2=value2 <?php echo $_GET['var1'] . '<br />'; echo $_GET['var2']'; ?> You should get the following out put: There are few precautions to make when handling GET data. As it is seen within the browser it can be easily changed by the user so it is important to validate any data coming in form GET, so if a variable is only supposed to contain a number use is_numeric to check to see if that variable is actually a number. Second of all do not pass sensitive information in the url such as passwords as any one within the view of seeing the browser will be able to read the contents of the address bar.
-
If you used the installer with IIS then it should work. Also the code you put in your test php file should be: <?php phpinfo(); ?> Short open tags(<? or <?=) will not work "out of the box". You have to configure the php.ini in order for short open tags to work.
-
I'd recommend WAMP.
-
Script/Program to convert '<?' into '<?php'
wildteen88 replied to guarriman's topic in PHP Coding Help
PHP5 does support the short tags (<? and <?php=) all you need to do is enable a setting called short_open_tag. However if your script is small then I'd recommend you to convert the short tags to their respective full version. -
You could do.
-
You should at least learn the basics which will help you get started. Without the basics you wont be able to understand much of the code. I would recommend you to read the manual. Read parts I and III Those chapters will help to understand PHP more. Also I recommend you to read this free ebook too. I would also recommend you install PHP locally so you run your scripts. I'd recommend WAMP for Windows or XAMPP for *nix (linux, unix etc).
-
Um // or /* */ are called comments. comments are ignored by PHP. Comments are useful if you need to set reminders for yourself on a piece of code
-
Try the following: function sieorform($formname, $sievalue) { if(isset($_POST["spara"])) { return $_POST[$formname]; } elseif(isset($_POST["SIE"])) { return eval("calculate_range($sievalue);"); } } sieorform(RRintNOcy, "'RES', 0, 3000, 3799"); What I have done instead is pass just the arguments for the calculate_range function as a string to the sieorform function. Then if $_POST["SIE"] isset and and $_POST["spara"] is not it'll run the calculate_range function with the passed parameters. NOTE: You will have to enclose the the parameters in quotes for the second parameter when calling the sieorform function otherwise the code wont work. Example: Correct sieorform(RRintNOcy, "'RES', 0, 3000, 3799"); Incorrect sieorform(RRintNOcy, 'RES', 0, 3000, 3799);
-
As you're passing calculate_range function as a parameter for the sieorform function PHP will run calculate_range function whether or not the form has been submitted or not.
-
[SOLVED] localhost Databse
wildteen88 replied to LordOrange's topic in PHP Installation and Configuration
Ugh! What did you do? If you did everything correctly then you should not have any problems. Also what http server do you have installed? Apache, IIS or something else and what OS? -
Its an if statement. With PHP you can go in 'n' out of PHP however many times you want. The above quoted code is the same as: <?php if($show_form) { echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post"> Firstname: <input type="text" name="firstname" value="' .@$_POST['firstname']. '" />' .@$msg1 . '><br /> Surname: <input type="text" name="surname" value=""' .@$_POST['surname']. '" />' .$msg2 .'<br /> <input type="submit" name="submit" value="check!" /> </form>'; } else { echo '<b>Form has been submitted!</b>'; } ?>
-
Nope. I do not give out email/IM or any other contact details over the net. Only to friends and family sorry. Once you have reached 10 or more posts you'll be able to PM. You can contact me via PM if you wish.
-
I did a bit of datatype verification. If a variables is supposed to be an array before I use it I always check to make sure it is an array. @ symbols do just that prevent php error messages from appearing. I usually don't even use the @ symbol in any of my code however I did in this case I was being a bit lazy
-
In that case theres your problem. PHP is a server side language. It is not a client side language like HTML/Javascript/CSS which your browser can read. In order for your to run your PHP files you'll need to install a http server configured with PHP. If you are new to PHP then I suggest WAMP (http://www.wampserver.com). WAMP is a pre-configured package which will setup Apache and PHP (and MySQL which is a database) for you so you can run your PHP scripts. Also I recommend you to watch the first video on this site for installing and how to use wamp
-
So are you running your files directly from your PC directly in your browser? and the address bar reads something like: file:///path/to/your/file or C:/path/to/your/file
-
Who is the webhost that hosts your site? You might want to contact your webhost for support as to why your php files are not running.
-
How are you running your PHP file? Please describe the process in which you run your html/php files.
-
<?php function calculate_range($source_file, $cat, $bool, $range_min, $range_max) { $contents = file($file); foreach($contents as $line_value) { list($_cat, $_bool, $_id, $num) = explode("\t", $line_value); $_cat = str_replace('#', '', $_cat); $number[$_cat][$_bool][$_id] = trim($num); } $total = 0; for($i = $range_min; $i <= $range_max; $i++) { if(isset($number[$cat][$bool][$i])) { $total += $number[$cat][$bool][$i]; } } return $total; } $file = $_FILES['userfile']['name']; // the source file $total = calculate_range($file, 'UB', -1, 1600, 1650); // calculate the range ?>
-
try: <?php $show_form = true; if(isset($_POST['submit'])) { if(empty($_POST['firstname'])) { $error['msg1'] = 'Please provide your firstname'; } if(empty($_POST['surname'])) { $error['msg2'] = 'Please provide your surname'; } if(isset($error) && is_array($error)) { extract($error); } else { $show_form = false; } } ?> <html> <body> <?php if($show_form): ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> Firstname: <input type="text" name="firstname" value="<?php echo @$_POST['firstname']; ?>" /><?php echo @$msg1; ?><br /> Surname: <input type="text" name="surname" value="<?php echo @$_POST['surname']; ?>" /><?php echo @$msg2; ?><br /> <input type="submit" name="submit" value="check!" /> </form> <?php else: ?> <b>Form has been submitted!</b> <?php endif; ?> </body> </html>
-
You have saved the file with a .php file extension? and that your website has PHP enabled? Also can define how you preview it?
-
@@chris_php please use code tags ( ) when posting large amounts of code within posts. Also it helps if you only post just the relevant parts of your code and not whole files. If you want to post whole files then attach them to your post.