wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
So this adds a backslash for some reason anyone know why?
wildteen88 replied to Demonic's topic in PHP Coding Help
You might have magic_quotes enabled. Use [code=php:0]set_magic_quotes_runtime(0)[/code] at the top of your script to turn off magic quotes for your script. Also I'd chnagew your script to this: [code=php:0]<?php // turn off magic quotes set_magic_quotes_runtime(0); if(isset($_POST['info'])) { $javascript = "javascript.txt"; if(is_writable($javascript)) { $open = fopen($javascript, 'w'); $script = $_POST['info']; fwrite($open, $script); echo "Written Successfully"; } else { echo "Couldn't write to File"; } } else { // this is a HEREDOC statement. echo <<<HTML <center> <form method="post"> <textarea name="info"></textarea><br> <input type="submit" name="post" value="post"> </form> </center> HTML; } ?>[/code] -
[quote author=onlyican link=topic=103976.msg414529#msg414529 date=1155391404] most servers have <? ?> and <?php ?> configured as standard whilst <% %> and <?= ?> are not normally if you are using a server with mixed ASP / php then <% %> will not as it is Standard ASP tags [/quote] Actually most servers have <?php and ?> and, <script langauge="php"></script> as standard. If you want to use <? ?> rather than <?php ?> you'll have to turn on the short_open_tag directive. This directive also allows you to use <?= ?> as shortcut to using <?php echo blah ?> If you want to use <% %> as PHP tags you'll need to turn on the asp_tags direcitve. Also note the following tags <? ?>, <% %> and <?= ?> will be removed as of PHP6.
-
Could you please explain in more detail what you are trying to. I dont get you mean.
-
PHP can try to change permission of direcotories/files using a functioin called [url=http://http:/www.php.net/chmod]chmod[/url]. Howeve this function is useless on a Windows box.
-
Noobie Stuff: Very Basics Explained Easily
wildteen88 replied to Pudgemeister's topic in PHP Coding Help
Noob, n00b, newbie is slang for someone being new to something. Usually you experience this sort of slang when playing online games. This [url=http://www.urbandictionary.com/define.php?term=noob]site[/url] exlpains this word. -
[solved] fun with fwrite mkdir unlink foreach rmdir thanks all
wildteen88 replied to redarrow's topic in PHP Coding Help
Well the problem you are executing this line: $a=mkdir(thedir); each time. Now when PHP goes through the loop the first time it creates the directory thedir, but the secound time it goes to create it again. But it cant as thedir already exists. So move [code=php:0]$a=mkdir(thedir);[/code] out of the for loop and place it at the top. Also remove [code=php:0]."<br>"[/code] from this [code=php:0]$dir=$rand[$i]."<br>";[/code] Now your code should now work. This is what you code should loook like: [code=php:0]<?php // we create the directory first mkdir('thedir'); for($i = 0; $i < 9; $i++) { $rand[$i] = rand(1, 5000); $dir = $rand[$i]; mkdir("thedir/$dir"); echo "Created thedir/" . $dir . "<br />\n"; } ?>[/code] -
Yeah I just found that out too, saw it posted on forgetfoo. Also thats the old site, they have jumped ship to [url=http://www.getswift.org]getswift.org[/url]
-
OKay. Looking at your your code, you are using strings but you aint put the quotes around them. When you use a string you need to place a quotes around it. Try this: [code]<html> <body> <title>Profile</title> <body bgcolor=336699> <div align=center> <table width=332 cellpadding=0 cellspacing=3> <tr> <td background=tableo.jpg style=border-top:3px red solid;border-bottom:3px red solid;border-right:36px red solid;border-left:3px red solid;> <?php $con = mysql_connect('localhost', 'ZackBabtkis', 'pass') or die('Could not connect:' . mysql_error()); $user = $_COOKIE['user']; mysql_select_db('test', $con); $result = mysql_query('SELECT about FROM users WHERE $user = user'); while($row = mysql_fetch_array($result)) { echo $row['about']; } echo '</table>'; mysql_close($con); ?> </td> </tr> </table> </body> </html>[/code]
-
As far as I can see there is no limit.
-
You have an ending php tag (?>) which doesnt seem to have an opeing PHP tag. Remove ?> from line 11.
-
You can easily work how many secounds are in a say 10 years by first working out how many secounds are in an hour, which is 3600 (60 (seconds in a minute) * 60 (minutes in an hour)) To get the numer of secounds in a day times 3600 by 24 which is 86400. Now times that by 365 days to get the total number of secounds in a year which is 31536000 secounds. Now times that by 10 to get the number of secounds in 10years.
-
Well with the WHERE Clasuse I'm sure you are supposed to have a column name and not a value from a column. Like: INSERT INTO table (field) VALUES ($value) WHERE col_name=$value1 You cannot use a column value on its own. i'm moving this to the MySQL Help forum.
-
There is no setting to make a session stay live for infinity. Instead what you'll want to do is use make it expire after a year use 31536000 as the value. if you want it last longer than a year multiple that number by the number of years you want the session to stay alive for. However a year is ample. As I dought most users kep their cookies for long.
-
oops, I didnt fix your sql query. Use this as the query [code=php:0]$sql = "SELECT * FROM staff WHERE `username`='$username' AND `password`='$password' AND activated='1'";[/code]
-
Are you put html/javascript in the url? Why are you tryiung to put html/javascript in the url!
-
You cannot do that. As the session is automatically destoryed when the user closes the browser, with or without a session.cookie_lifetime. If you are doing a login type system any you want the user to be logged in all the time, you'll want to setup a cookie which holds a special id to restart the sessions again whne the user returns.
-
If want it to be infinitie I believe you can use 0 as the value This will mean the session will stay alive until the user closes the browser.
-
Have a try of this: [code=php:0]<?php error_reporting(E_ALL); ini_set('display_errors','on'); // before we do anythink we first check that we have the username and passsword vars: if(isset($_POST['username']) && isset($_POST['password'])) { // now we attempt to log the user in // connect to MySQL $conn = mysql_connect("localhost" ,"www2", "accuoffice"); //select the database $db = mysql_select_db("accu") or die("Unable to select database"); // prepare our username and password vars $username = mysql_real_escape_string($_POST['username']); $password = md5($_POST['password']); $sql = "SELECT * FROM staff WHERE username='$username' AND password='$password' AND activated='1')"; $result = mysql_query($sql); // check that only 1 result was returned if(mysql_num_rows($result) == 1) { // now that we know the user has succesfully logged in we'll start the session session_start(); // mysql_fetch_assoc returs an associative array. // Check out php.net/mysql-fetch-assoc for more info on this function $user = mysql_fetch_assoc($result); // we'll use a foreach loop to create our session variables automatically! foreach($user as $key => $value) { // $key is the key used in the $user array // $value is the valye of the key. // for example $user holds an array. The first item in that array will be $user['firstname'] // this holds the firstname of the user // notice in the square brakets there is the word firstname in quotes. This is called the array key ($key) // This key holds the users firstname ($value). // This is basically what this section of code is doing. $_SESSION[$key] = $value; } mysql_query("UPDATE staff SET last_login=now() WHERE userid='$user[userid]'"); header("Location: login_success.php"); } else { echo "Logging was unsuccessful. Please try again"; } mysql_close(); } else { echo "PLease ensure you have filled in the username and password fields"; } ?>[/code] This should be what you are looking for. Have a read of the comments (orange text) if you are unsure whats happening.
-
Ruby on Rails is standalone server side lanaguage. You cannot mix it in with PHP. If you want to create a ruby on rails site you use ruby on rails. Just like you do if you want code in ASP. You cant mix ASP with PHP as they are completly different lanaguges. The same applies to Ruby on Rails.
-
Try going ot Edit > Preferences > Code Format Look for Automatic Wrapping, uncheck the checkbox next to it. Click Ok and OK again.
-
Please post more information. What do you mean by table, what you want to be displayed in the table?
-
1st Apache Install... 1st Apache Issue... eeeek maybe?
wildteen88 replied to TerryGirl's topic in Apache HTTP Server
These shouldn't stop Apache from running. The first error most people will get anyway, as on every page reguest Apache tries to find a file called favicon.ico, this can be disabled. But is used by the browser. However the secound error, appears to be file you are trying to request in your browser which doesnt exists, as you shouold get a 404 error message. -
You can use eval to execute PHP code within a string. However be extremely careful when using eval. If a cracker finds out you are using eval, he can put in some nasty PHP code, which could pertentialy delete every file for your website/database!!
-
How to upgrade 4.4.2 -> 4.4.3 in win XP
wildteen88 replied to slongmire's topic in PHP Installation and Configuration
Just extract the contents of the zip to C:\php overwritting any existing files and thats it. You should be upgraded.