-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
Rather than have two templates one with a searchbox and the other without. Instead have one template for your sites over all layout. You then extract elements from that template into smaller template files which you only include when you need them. Ie in your templare file you have something like this <html> <head> <title>Site Title</title> ... etc </head> <body> ... <?php // if user logged in include the searchbar template if($user_login) include 'searchbar.php'; ?> ... <body> </html> Searchbar.php will only contain the HTML for your searchbar. The searchbar will only be shown if $user_login is true.
-
All your classes are located in the classes folder. In config.php there is a constant called CLASSES_DIR . This contains the path to where your classes are located. Prepending CLASSES_DIR to $path should now allow the autoloader to find the class files within your classes folder require_once($path); should be require_once(CLASSES_DIR . DS . $path); //OR require_once(ROOT_PATH . CLASSES_DIR . DS . $path);
-
Also what is the the n1Emails class used for? You seem to return the results as an associative array and then convert the results into a object manually. PDO can return the results as an object, use PDO::FETCH_OBJ instead of PDO::FETCH_ASSOC.
-
What api are you using? PDO or MySQLi? You can only use one or the other you can't use them both together. If you are inserting data into the database you should be using prepared statements. The PHP documentation has clear documentation for how to use prepared statements for both api's PDO Prepared Statements MySQLi Prepared Statements
-
So you are wanting display a table of results. And then you'd have a textbox where the user can type in a username to filter the results by? Ie you type in PRO_Viking and it'll only show their results?
-
No not quite. The if statements will be outside of the array. You save the new color to a variable and pass that variable to setBarColor(). Example if(condition 1) { $color = new Color(42, 121, 66); // if condition 1 is met set color to this } elseif(condition 2) { $color = new Color(98, 88, 161); // if condition 2 is met set color to this } elseif(condition 3) { $color = new Color(24, 66, 201); // if condition 3 is met set color to this } else { $color = new Color(42, 71, 1); // the default bar color } $this->setBarColor(array($color)); // pass the color to setBarColor method.
-
avshelestov solution is correct. Although $your_text needs to be changed to $string and you need to add a third argument to preg_match_all to return the array of matches. Example code. $items = preg_match_all("!Luas\s+Bangunan\s+:\s+(\d+)!si", $string, $matches); echo "Found $items instances of Luas Bangunan. The values are : ' . implode(', ', $matches[1]);
- 5 replies
-
- explode based on string
- regex
-
(and 3 more)
Tagged with:
-
Using mysqli is not as simple as just placing i infront of mysql in the function names. Look at the mysqli documentation for how to use it correctly. Also please wrap code within tags when pasting code.
-
Printing the IP Address From Which the Site is Viewed on Screen?
Ch0cu3r replied to glassfish's topic in PHP Coding Help
That is what $_SEVER['REMOTE_ADDR'] is for. It returns the IP address to the remote user. You are getting ::1 because you are accessing your server locally using IPv6. To see 127.0.0.1 as the IP you need to use IPv4. To use the IPv4 either uncomment ::1 localhost from your hosts file (or disable IPv6 on your Network Adapter - not recommended). -
how to access xampp server on a local home network
Ch0cu3r replied to ajoo's topic in Apache HTTP Server
Make sure you have typed the word IP in lowercase! Any valid IPv4 (or IPv6) address is accepted. I have tested the following and its fine for me. <LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))"> Require local Require ip 192.168.2.104 ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var </LocationMatch>- 6 replies
-
- 1
-
- ajoo
- simple xampp server client
-
(and 1 more)
Tagged with:
-
how to access xampp server on a local home network
Ch0cu3r replied to ajoo's topic in Apache HTTP Server
Try adding the following in the httpd-xampp.conf file Require ip <ADD YOUR WINDOWS XP LAPTOP LAN IP ADDRESS HERE> After this line Require local Save the file and restart the Apache service from the XAMPP control panel. You should now be able to access the xampp homepage from the Windows XP laptop- 6 replies
-
- ajoo
- simple xampp server client
-
(and 1 more)
Tagged with:
-
mysql_fetch_row() expects parameter 1 to be resource, boolean given
Ch0cu3r replied to Moez's topic in PHP Coding Help
This error usually indicates the query has failed. To see why the query has failed you can use mysql_error. Example $query = mysql_query("SELECT * FROM books LIMIT 5"); if(!$query) { trigger_error('MySQL Error: ' . mysql_error()); } Also why are you defining $connection as global even though you don't use that variable in the function? If your function does require this variable you should pass it as an argument when you call the function. -
how to access xampp server on a local home network
Ch0cu3r replied to ajoo's topic in Apache HTTP Server
If the two computers are on the same network you shouldn't need to configure anything. On the XP laptop instead of accessing http://localhost you'd use the Windows 7 laptops LAN address, eg http://192.168.2.107 If you dont want to keep typing the IP address you can add an entry to Windows hosts file and alias the Windows 7 IP address to a hostname. eg 192.168.2.107 localhost.win7 You can then use http://localhost.win7/ to access the site on the Windows 7 laptop.- 6 replies
-
- ajoo
- simple xampp server client
-
(and 1 more)
Tagged with:
-
Not sure but I'd assume you could just change 192.168.1.6 to the users actual IP Address (could use $_SERVER['REMOTE_ADDR'] to do this). However the user will then need to configure their router to forward port 8888 to their arduino's internal LAN address (192.168.1.6).
-
cURL Image Upload Works on Local XAMPP, But Not Web Server
Ch0cu3r replied to dlebowski's topic in PHP Coding Help
The following is local file path for your PC and not the server $image="C:/Desktop/Sample Images/usco1.jpg"; usco1.jpg needs to be located on the server you are running the code from. PHP cannot access remote users file systems. -
How would we know why the file is in another directory? We are not sat beside you. It would be helpful if could actually explain what it is you are trying to do. Just posting a few lines of code is not going to yield you any helpful replies. Also if you are getting any error messages post them in full.
-
You mean to say the images are being loaded from localhost and not asaphshop.nl This is because the urls to the images does not include the url to asaphshop.nl. The urls to the images look like this /WebRoot/AsaphNL/Shops/.../80203122_xs.jpg (shortened). They all begin with a forward slash. When a url starts with a / it means the root of the current url, which in your case it'll be localhost. In order for the images to load from asaphshop.nl you need to replace the / at the start of each image url with http://asaphshop.nl/ Example code $image = $matches[0]; $image = str_replace('src="/', 'src="http://asaphshop.nl/', $image); echo $image; // image should be loaded from asaphshop.nl Alternatively use array_map to perform the operation for all images in the array $matches = array_map( function($item) { return str_replace('src="/', 'src="http://asaphshop.nl/', $item); }, $matches); print_r ($matches);
-
Help with understanding echo "</"; effects thereafter.
Ch0cu3r replied to mprpjo's topic in PHP Coding Help
It has nothing to do with the array. As I said eariler the browser is seeing the </ and treating it as HTML markup, identifying it as the start of a closing HTML tag. This is why text after it it does not display. To stop the browser from treating it as HTML you need to sanitize it. As I mentioned earlier applying FILTER_SANITIZE_SPECIAL_CHARS to the array causes the < to be converted to ASCII code which is < The browser will parse the ascii code and display the < character. You need to Right click > View source to see the actual output. -
Does not matter in what order or whether you use the functions at the same time. The end result will be the same. trim() removes white space characters at the start and end of a string strip_tags() removes html tags from a string. If you are having to pass messages in the url I would recommend $_SESSION instead. Anything in the URL can be changed by the user.
-
Help with understanding echo "</"; effects thereafter.
Ch0cu3r replied to mprpjo's topic in PHP Coding Help
@mprpjo What is it you are trying to do? The reason for the output is because the FILTER_SANITIZE_SPECIAL_CHARS flag will HTML escape characters such as single, double quotes, angled brackets and ampersands into their ASCII counterparts. NOTE: when you post code please wrap it within tags or click the <> button in the post editor. -
Help with understanding echo "</"; effects thereafter.
Ch0cu3r replied to mprpjo's topic in PHP Coding Help
@ginerjm. The OP is seeing the results in the browser. The browser has parsed the </ as HTML this is why you only see the double quote. As for the 6 char string the </ has been html escaped to </ The actual output to the OP's code is this <pre>array(2) { [0]=> string(2) "</" [1]=> string(7) "message" } <pre>array(2) { [0]=> string(6) "</" [1]=> string(7) "message" } -
First set your tags column as a UNIQUE KEY in the database Then use an INSERT IGNORE INTO query when adding the tags to the table. This will then prevent duplicate tags from being added to your table.
-
You have exit; at the end of each of your if/elseif statements (see below what i mean). This will halt your script no matter if your conditions are met or not. if ($type == 'Annual Leave'){ $annual = $fest['annual']; if ($annual == '0') { echo "Sorry, you don't have any $type leave days available."; exit; } else if ($workingDays > $annual){ echo "Sorry, the number of days you are requesting is more than the number of days you have left. "; exit; } exit; // <---- this will kill the script no matter what } Instead of using exit all over the place. You should instead use a variable, which you initially set to true. You will set this to false when your data does not validate. You'd then only execute the query if this variable is still true.
-
You need to use something like this to get the results from the query // use a while loop to loop over the rows returned by the query while($row = odbc_fetch_array($rs)) { echo '<pre>' . print_r($row, true) . '</pre>';; // show contents of row } Manual page on odbc_fetch_array