wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
Why dont you move [code=php:0]include($TEMPLATE_DIR . 'face_end.php');[/code] at the end of case 0. So find the following: [code]break; } case 1: {[/code] Now add [code=php:0]include($TEMPLATE_DIR . 'face_end.php');[/code] before [b]break;[/b]
-
There is a predefined variable which stores the users IP address. $_SERVER['REMOTE_ADDR'] is the variable you want to use in order to retrieve the users IP Address. Note dont rely on this as users IP addresses can change frequently and can be easily changed.
-
Huh! PHP 7.8 AFAIK the current most recent version is 5.1.4 If you want to create your own counter script there are thousand of tutorials out there for doing so.
-
Something like this: [code]if(isset($_POST['submit'])) { if(!ereg("^[A-Z]{2}[0-9]{1,2} ([0-9]{1}[A-Z]{2})%body%quot;, strtoupper($_POST['postal']))) { echo '<i>'.$_POST['postal'].'</i> - invalid postal code'; } else { echo '<i>'.$_POST['postal'].'</i> - valid postal code!'; } } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="text" name="postal" value="<?php echo @$_POST['postal']; ?>"/><br /> <input type="submit" name="submit" value="Submit" /> </form>[/code]
-
Change: [code]$result = mysql_query($User_SQL, $DB_Server);[/code] to the following: [code]$result = mysql_query($User_SQL, $DB_Server) or die("Unable to perform query: {$User_SQL}<br />\n" . mysql_error());[/code] When you run your code again what do error do you get?
-
mkdir and chmod are only effective for the PHP script. It wont set the permission for the folder/file forever If you want to ftp stuff to the folder you can do by logging in to your FTP client, going to the folder, right click it and select properties or change permissions. You sholud be able to change the permissions for the file/folder. If not your host may have disabled this or the server is a Windows server and doesnt support CHMOD permissions.
-
For the UK Postcode I have this: [code]^[A-Z]{2}[0-9]{1,2} ([0-9]{1}[A-Z]{2})$[/code] Here is a step through of what above expression does: [A-Z]{2} - Check the first two characters of the Postal code are letters from a through to z [0-9]{1,2} - Checks that there are at least one or two characters after the first two are numbers, from 0 - 9 [0-9]{1} - Does the same as above, but checks the the next character is a number after the space [A-Z]{2} - Check the last two characters of the Postal code are letters from a through to z Here it is action: [code=php:0]$regexp = "^[A-Z]{2}[0-9]{1,2} ([0-9]{1}[A-Z]{2})$"; $postal = 'AB1 2BC'; if(!ereg(strtoupper($regexp), $postal)) { echo '<i>'.$postal.'</i> - invalid postal code'; } else { echo '<i>'.$postal.'</i> - valid postal code!'; }[/code]
-
Urlencode will not help. But what you might want to do is to create an array of all the pages that are in different directories. The use an if statement to check the page being included if its in the array of pages in different directories. If it is use the path in the array for that page. Sounds complicated? Its not but very straight forward if you understand arrays. Heres a quick demo of what I mean: [code=php:0]<?php // check that 'page' is set in the url if(isset($_GET['page'])) { // now we setup our array of pages in different folders // the following is the format of our array: // array([pagename] => array([filename], [path to file])); // Our pages array $pages = array("about" => array("index.php", "./about/"), "contact" => array("contact.php", "./pages/"), "products" => array("list-products.php", "./shop/") ); // Now we check wether the page needed to be included is in our pages array if(array_key_exists($_GET['page'], $pages)) { // now we include our page: echo "include '" . $pages[$_GET['page']][1] . $pages[$_GET['page']][0] . "';"; } // if it wasn't we presum its its in the same folder as this script else { echo "include './" . $_GET['page'] . ".php';"; } echo "<br />\n<br />\n"; } ?> Include: <a href="?page=about">About page</a> | <a href="?page=contact">Contact page</a> | <a href="?page=products">Products</a> | <a href="?page=home">Home</a>[/code]
-
The problem is you are not using the variables you have defined in your class. In order to refer to the class variables you'll need to use $this->varname in order access the variables within the class. Otherwise the variables you use within a function will not eference variables outside of the function. So when you use $item or $items you'll want to use $this->item and $this->items with in your methods (the functions). In order to understand this behaviour you might want to read up on variable-scope
-
Change this: [code]$message = preg_replace("/\[\[\member:(.*?)\]\]/si"[/code] to the following: [code]$message = preg_replace("/\[\[\member:{$alias}\]\]/si"[/code] The problem was with the (.*?) as its was always getting the first member from the $message variable, Now that you chnage (.*?) with the $alias variable it gets all the correct data!
-
Newbie - for real! Just getting started!
wildteen88 replied to ummzee's topic in Editor Help (PhpStorm, VS Code, etc)
Umm that is asking you to enable an old setting called register_globals which can lead to security vulnerabilities. Could you provide the name of the script you are using? -
Huh! ??? What! I am failing to understand what you are trying to do. Could you explain what you are trying to do more clearly please.
-
messages displayed to browser for image uploading
wildteen88 replied to paulgc34's topic in PHP Coding Help
The cause is in uploadphotos.php on or around line 6. Could you post line 3 - 9 here so we can have look. -
Well the for loop is working, as I have tested it, although I striped out your code and used little bit code to echo the mataches preg_match_all has found, This is the code i used: [code=php:0]$message = "[[member:Daniel]] ta [[member:Steve]] tra [[member:Aaron]] la [[member:Maxwell]]"; $prepareCount = preg_match_all("#\[\[member:(.*?)\]\]#si", $message, $prepare); for ($i = 0; $i < $prepareCount; $i++) { $alias = $prepare[1][$i]; echo $i . ' - ' . $alias . "<br />\n"; }[/code] I assumed you was getting a memebers name of some kind. The result I get is the following: [code]0 - Daniel 1 - Steve 2 - Aaron 3 - Maxwell[/code] Which backups up the for loop is working. What appears to be the problem is the following: [code]$message = preg_replace("/\[\[member:(.*?)\]\]/si", "<img src=http://global.typekill.net/flags/$row[country].gif> <a href=members.php?mode=profile&id=$row[member_id]>$row[alias]</a>", $message);[/code] All the other code is you have is fine. The only thing I can recommend is to wrap your variables in curly braces ({}), for example: {$row['country']}
-
Basically what that message is saying a table called category could be found within the namibial_links database. Check the table has been created by using a tool called PHPMyAdmin, most hosts provid this tool. If its not then the installer may not be installing the tables correctly. If thats the case you might want to to contact the company/ or owner of the script for help on this matter.
-
Most of the time any errors you get are usually caused by the first error, so you fix the first error then if the errors dont clear you'll try to fix the next error and the one after that, untill all errors are gone. But when you fix the first error you usally fined that most if not all errors get fixed in the process. Also you'll need to connect to the database in order for your script to work, as the code snipet I told you to change stops the script from runnning if there is an error with performing the sql query.
-
There'll be no difference between the two methods, well there will be but you will hardly notice the difference as there will probably be less than 0.001 secounds difference between the two methods. I'd rather go for method 1 as it splits the code up into more manageable bits as each page will be in its own file, therefore you dont have go through a large file to edit a few lines of code for a certain page, as well as keeping the switch statement clean and easier to read etc.
-
Newbie - for real! Just getting started!
wildteen88 replied to ummzee's topic in Editor Help (PhpStorm, VS Code, etc)
Okay every think is now working fine. However this error: [code]Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in C:\Program Files\xampp\htdocs\ghani_website_test\shop\index.php on line 39[/code] Is to do with an error within index.php on line 39. Could you post lines 30 - 40 from index.php here for us to review it for what can be causing this. -
The reason its doing that is because you are outputted text/html to the browser before you use setcookie and the header function These functions cannot be used after there has been output. As they need to send header information to the server, but the header information has already been sent by the text/html. The way to fix this is add ob_start(); after your opening <?php tag and add <?php ob_end_flush(); ?> after your closing html tag, line 213, so your code looks like this: [code=php:0] 1 <?php 2 ob_start(); // rest of lines 213 </html> 214 <?php ob_end_flush(); ?>[/code]
-
Newbie - for real! Just getting started!
wildteen88 replied to ummzee's topic in Editor Help (PhpStorm, VS Code, etc)
OKay reading the XAMPP site you are supposed to put your files in a folder called [b]htdocs[/b] within the xampp folder eg: C:\program files\xampp\htdocs Now to test this has worked, by opeing your web browser and typing in the following: http://localhost/ghani_website_test/ Do you get anything displayed in the web browser? Also try http://localhost/ on its own too. What do you get? -
Its becuase parse_url includes the subdomain with the host name So basically your if statment will be doing this: if maindomain.com is not equal to subdomain.maindomain.com then echo "[i]Must be from same domain[/i]". To make this work you want to use eregi or use substr and get the last 14 characters from $rparseurl, which will be maindomain.com, then compare the last 14 chars with your $lparseurl['host'] variable.
-
Display all entrys in MYsql database on php page
wildteen88 replied to alcoholic1's topic in PHP Coding Help
Have a read of [url=http://www.php-mysql-tutorial.com/php-mysql-select.php]this tutorial[/url] for getting data out of the database. -
All the errors your are getting is becuase of the first error message which is: [i]Warning mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/myusername/public_html/abc.php on line 8[/i] You normally get this error message bacause you have an error within your query. To se what the problem is change this: [code]$qryxyxTotal = mysql_query($query);[/code] to the following: [code]$qryxyxTotal = mysql_query($query) or die("Nnable to perform query: <code>" . $query . "</code><br />\n The error returned was: " . mysql_error());[/code]
-
Try this instead: [code=php:0]if (isset($_GET['page']) and $_GET['page'] != "") { $p = $_GET['page']; } else { $p = "main"; } if (strpos($p, "..")) { die("Bad page request"); } $content_file = $_SERVER["DOCUMENT_ROOT"] . "/" . $p . ".php"; if (!file_exists($content_file)) { header("Location: {$_SERVER['PHP_SELF']}"); exit(); } $title = ($p) ? "$p - My Site!" : "Main page - My Site!"; include("header.php"); include($content_file); include("footer.php");[/code]