wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
[SOLVED] Echoing arrays through a for() statement
wildteen88 replied to bloodgoat's topic in PHP Coding Help
Use full PHP tags (<?php ?>). Short tags (<? ?> or <?= ?>) are normally disabled. Also you can develop/test your scripts locally if you installed what is known as the AMP stack (Apache, PHP and MySQL). That way you don't have to use a host to test your scripts. You can either install Apache, PHP and MySQL yourself or install preconfigured packages such as WAMP (for Windows) or XAMPP (for Windows, *nix or Mac). -
[SOLVED] Echoing arrays through a for() statement
wildteen88 replied to bloodgoat's topic in PHP Coding Help
Your code should work fine as it is. Are you sure you're echoing the $table variable after your loop. -
Your code is will not work unless register_globals is enabled, this setting is now disabled as default (as from 2002) and is soon to be removed from the upcoming release of PHP6. To fix you script $save_file should be $_POST['save_file']; $savecontent should be $_POST['savecontent']; Where is $username and $sitename coming from?
-
[SOLVED] Echoing arrays through a for() statement
wildteen88 replied to bloodgoat's topic in PHP Coding Help
This if(!$i){ die("Nothing here yet! "); will stop your loop at the first iteration as $i will be set to 0 which means false. Also you'll need to echo your $table variable for any output to be displayed. -
[SOLVED] display images from a databse?
wildteen88 replied to andrew_biggart's topic in PHP Coding Help
What is outputted to the browser (Right click View Source). What does $rows['Profile_picture'] contain? -
looking for a program for php+html+ajax...
wildteen88 replied to dima1236's topic in Editor Help (PhpStorm, VS Code, etc)
Have a look at Aptana Studio -
Did you see the code snippet at the bottom of my page. Thats all you need to have. You just add the code/text you want displayed when the user is logged after the line that says // rest of your code here. The code before that line prevents the user from accessing the page if they are not logged in.
-
First of don't use functions such as session_is_registered or session_registered. These are depreciated and should only be used if register_globals is enabled, which you should NEVER enable as that too is depreciated and is to be removed completely as of PHP6. When setting or accessing session variables just use the $_SERVER superglobal as you would with $_GET or $_POST superglobals. So I'd change this session_register("username"); session_register("password"); session_register("groupid"); to $row = mysql_fetch_assoc($result); // get the results from the query $_SESSION['username'] = $row['username']; $_SESSION['groupid'] = $row['groupid']; Now to see if the user is logged in on your pages do this simple check <?php // always call session_start on any page that uses sessions session_start(); // if the username or groupid session variables are not set then user is not logged in! if(!isset($_SESSION['username'], $_SESSION['groupid'])) { // user is not logged, redirect the user or display a message echo 'Please login to view this page!'; exit; } // rest of your code here ?>
-
If you cannot find the php5apache.dll or php5apache2.dll or php5apache2_2.dll then ensure you have downloaded the correct php package from php.net. Should be the one titled as PHP 5.2.9 zip package [10,266Kb] - 26 February 2009. Just extract the contents of the zip to C:/php and configure Apache as corbin described in his post above. Note When it comes to adding this line: LoadModule php5_module "/path/to/php/folder/php5apache2_2.dll" Ensure you use the correct .dll. PHP comes with three .dlls for apache here is what they are used for php5apache.dll is for Apache 1.3.x only php5apache2.dll is for Apache2.0.x only php5apache2_2.dll is for Apache2.2.x only You should also rename php.ini-recommended to php.ini within your php installation folder. It is also a good idea add PHP to the Path Environment Variable.
-
[SOLVED] .htaccess 2x rewriterules in a single url?
wildteen88 replied to daveoffy's topic in PHP Coding Help
$_GET is unsafe if you don't validate/sanitise user input correctly. As site and filedid only pass a number it is easy to validate the input. Like so: // check that fileid and site is present in the url // and check to see they contain only numbers. if(isset($_GET['fileid'], $_GET['site']) && is_numeric($_GET['fileid']) && is_numeric($_GET['site'])) { // filedid and site are now safe to use $fileID = $_GET['fileid']; $siteID = $_GET['site']; // rest of your code follows here } -
[SOLVED] .htaccess 2x rewriterules in a single url?
wildteen88 replied to daveoffy's topic in PHP Coding Help
Just expand your rewrite rule further # matches: /fileid/X/site/Y RewriteRule /fileid/([0-9]+)/site/([0-9]+)$ editor.php?fileid=$1&site=$2 [L] -
You could you use glob much shorter syntax. $php_files = glob("*.php"); echo '<pre>'.print_r($files, true).'</pre>';
-
If you want to log errors globally then setup the error_log directive to the location you want all errors to be logged to. You should also enable the log_errors directive too However if you want to log errors temporarily to different location the use ini_set within you script eg <?php ini_set('log_errors', 'On'); ini_set('error_log', '/path/to/your/script/error.log'); // rest of your code ?>
-
Why can't I use the GET method on a mod_rewrite'd page?
wildteen88 replied to dezkit's topic in Apache HTTP Server
with that url everything is being rewriten to index.php?url=/home?link=hello -
Do you want to format a unix timestamp to a 12 hour format? have a look at the date function.
-
Yes all templates are stored within the database. To edit them you'll have to login to the AdminCP area and there should be a Theme/Template menu to the left and then you can edit each template bit separately.
-
Most probably anyone that is on your LAN will be able to access phpMyAdmin if you dont protect it in someway. Also if your computer/router is setup to allow external connections to port 80 anyone from the internet will too. One simple step you could do is to only allow certain IP addresses to access the /phpmyadmin directory. To prevent anyone but localhost connections to access phpmyadmin place the following within a .htaccess file and save within the root of the phpMyAdmin directory Order Deny,Allow Allow from 127.0.0.1 You can add other IP addys too to the list.
-
Not its most probably your browser caching the page. Next time try a Ctrl + F5 to force your browser to reload a fresh copy of the requested page.
-
[SOLVED] How can i get get a variable from a while loop
wildteen88 replied to madspof's topic in PHP Coding Help
Example of how I'd do it. <?php include "connect.php"; $res = mysql_query("SELECT * FROM users"); $listItems = null; while($row = mysql_fetch_assoc($res)) { $class = ($row['Authorised'] == 1) ? 'auth' : 'noauth'; // generate the <options></options> into the $listItems variable $listItems .= "<option class=\"$class\">{$row['Username']}</option>\n "; } ?> <html> <head> <title>Untitled Document</title> <style type="text/css"> <!-- .auth { color: black; } .noauth { color: red; } --> </style> </head> <body> <form name="form1" method="post" action="changearound.php"> <p align="center"> <select name="username" size="20"> <?php echo $listItems; ?> </select> </p> </form> </body> </html> -
Have a look into the $_SERVER or $_ENV supergloabls maybe something is set in there. But I dont think there is. Or you could run the whoami command via exec
-
You do not use PHP to layout your webpage. This is handled by HTML/CSS you just need to echo out the relevant HTML/CSS tags/attributes to position your image.
-
Use is_numeric