laffin
Members-
Posts
1,200 -
Joined
-
Last visited
Everything posted by laffin
-
Thats wut the link was for, the link formats yer code for u once u have it formatted, it should be pretty easy to spot where the unbalanced paren is.
-
Rule #1 RTFM Rule #2 Indent U cant figure out the balance of parens cuz they all over the place http://www.phpformatter.com/ This should help if yer editor dun indent for u
-
parsing a php file and then grabbing it's contents
laffin replied to envexlabs's topic in PHP Coding Help
how would eval help when the file doesnt have the extension of php, but html? -
LOL Its good to learn new things
-
I think thats why I chose a modular system over a plugin system. I didnt need an api, as the modules developed for this system, have a 1 time use and dont need interaction with each other.
-
parsing a php file and then grabbing it's contents
laffin replied to envexlabs's topic in PHP Coding Help
check to see if yer php/apache installation suppoerts path info if it does just call the page as http://site.com/script.php/output.html -
I can show u one of the module systems I wrote up. Its for a basic web server development. QuickPHP Module Loader
-
$iso_date isnt a column and e_start and e_end arent values u got them mixed up My guess is u wud use WHERE e_start >= $iso_date AND e_end <= $iso_date
-
This really depends on how You want to implement plugins/modules. I have built two different type of module systems. They work pretty similar. It's just one takes info from a db the other takes info from the script itself (allowing the owner to include the modules). These are filebased, and are included into the script than ya have systems which keep the entire module in the db, I believe this will be eval'd later. The module systems I have made, are just base engines (meaning they dont do nothing themselves except load in the various modules). The modules themselves dictate wut they display/do. than you have a plugin system, which does involve setting up hooks and the like. where u have a standard api. which gives the base system more functionality.
-
did u look at strtotime? Echo "Yesterday was: ". date("m/d/y",strtotime("-1 day"));
-
How to create "speed bump" or capture an outbound link
laffin replied to jbutler's topic in Javascript Help
Okay with some standard coding here, here is redir.php this should work, as an example <html> <head> <title>HTML Redirect Ad Example</title> <?php // Check for a url field, otherwise send to default page $url=(!isset($_GET['url']))?'index.php':urldecode($_GET['url']); // Javascript insertion detection if(preg_match( "/([<>'\"]|'|!|"|%27|%22|%3E|%3C|'|"|>|<|\.js)/i", $url )) $url='http://www.urbandictionary.com/define.php?term=twat'; // Fix up any unprefixed urls if (substr($url, 0, 4) == "www.") $url = "http://" . $url; ?> <meta http-equiv="refresh" content="5;<?php echo $url; ?>"> </head> <body> <?php $ads=array('google','yahoo','msn'); $show=rand(0,count($ads)-1); ?> <h1>Ad for <span style='color: red'><?php echo $ads[$show]; ?></span></h1> </body> </html> to use the code in yer site $redir="redir.php?url=".urlencode("http://www.google.com"); and that should do it Note: Now if some moderator would be kind enough to move this thread back? Good Luck -
I use a portable php environment for testing. QuickPHP (Small development server) PHP 5.2.29 (Stripped down for bare essentials) Dev-PHP2 (PHP Development IDE) These are portable and run under windows. At home, I use UltraEdit (Commercial) Zend Studio (Commercial) But if yer looking for a small portable editor. npp++ (Notepad Plus Plus, is a good replacement) There are plenty of other editors, but if yer just getting started, I wud suggest one that is meant to work with PHP, as this will give u some unique benefits for php programming.
-
did u reset/unset the array element? sounds like yer reusing the array, but never clear it, either redefine the array or unset the variable
-
How to create "speed bump" or capture an outbound link
laffin replied to jbutler's topic in Javascript Help
U can use a php redirector script instead if yer links were like: http://mysite.com/redir.php?url=xxxx u wud have to use urlencode, to encode the original url. -
Exactly
-
Yes But I was thinking of 2 rows | A B C D E F | 1 2 3 4 5 of A's something like that, which isnt hard to do
-
I think a combination of the two would work. Its hard trying to find L's when ya got numbers. and its a pain to have to go throu a page of 200 entries so if ya have both, Letters on top, pagination below, it shud be a nice directory navigation system
-
file: download.php <?php if(isset($_GET['id'])) { include '../library/config.php'; include '../library/opendb.php'; $id = $_GET['id']; $query = "SELECT name, type, size, path FROM upload2 WHERE id = '$id'"; $result = mysql_query($query) or die('Error, query failed'); list($name, $type, $size, $filePath) = mysql_fetch_array($result); header("Content-Disposition: attachment; filename=$name"); header("Content-length: $size"); header("Content-type: $type"); readfile($filePath); include '../library/closedb.php'; exit; } ?> if yer using notepad and a linux server that could be the problem. windows uses a line terminator of CR + LF while linux uses only LF it shud look like this. header lines shud be on 12-14 not 14-16 to display images u need to change $query = "SELECT id,name, size FROM upload2"; to $query = "SELECT id,name, size,path FROM upload2"; and list($id,$name, $size) = $listing; echo "<a href=\"download.php?id={$id}\">{$name}</a>- {$size}<br />\n"; to list($id,$name, $size, $imagepath) = $listing; echo "<img src=\"$imagepath\"><br />\n"; that should do it
-
U mean like adding user Ratings, Comments, Popularity (hits)? I guess it depends on how u want to cycle/rotate the directory. if there arent that many, u can just retreive the id's shuffle em, and then use the query. storing the shuffles id's in a cookie/session (so its different for every user). to save space, u can use the pack function. Edit: U can also just have 2-3 companies at the top, a featured or similar concept.
-
PHP Beginner- in school- HORRIBLE Teacher- I am lost!!! HELP!
laffin replied to LostinSchool's topic in PHP Coding Help
That cleans up the data after submission. it adds backslashes to the message as to prevent some injections. Like I said work on the form first. than move onto the processing/display scripts. -
PHP Beginner- in school- HORRIBLE Teacher- I am lost!!! HELP!
laffin replied to LostinSchool's topic in PHP Coding Help
Well its not the submit, that just sends something to the server its the other form elements you use for your data. if this was not explained, or wut data to use. U can prolly come up with a few idea Address Book - Name Address City State Zip Reciepes - Name, ingrediants, instructions etc etc etc so either follow the assignment, if it doesnt limit u to what, than come up with something -
check for spaces before <?php tags or any spaces after ?> tag spaces at these two points can cause that error the code I posted I spotted a type change ist($id,$name, $size) = $listing; to: list($id,$name, $size) = $listing;
-
<B> with html_entities wud produce <B> but if this is going into a db, remember the mysql_escape_string
-
Okay had some time to write some code for an example <?php header('Content-type: text/plain'); $msg = "Hey ##CUSTOMER_NAME##, This is in reference to ##PURCHASE_PRODUCT## purchased on ##PURCHASE_DATE##. This is to confirm we will be sending it to ##CUSTOMER_ADDRESS## ##CUSTOMER_CITY##, ##CUSTOMER_STATE## ##CUSTOMER_ZIP##"; // bogus entry entry (this is where ya wud call customer/purchase info $customer = array( 'name' => 'John Doe', 'address' => '123 Happy Ln', 'city' => 'Sunny', 'state' => 'CA', 'zip' => '99999' ); $purchase = array( 'date' => '9/9/09', 'product' => 'php tutorials', 'quantity' => '50' ); function my_vars($matches) { global $customer, $purchase; $main=strtolower($matches[1]); // Get our Array Variable name $sub=strtolower($matches[2]); // Get our Array Element Name $var=$$main; // Map to our Array Variable if(isset($var[$sub])) // Does the Array Element exist? { $ret = $var[$sub]; // Return the Element } else { $ret = $matches[0]; // Return original pattern } // Conditional Example if($main=='customer' && $sub=='state' && $ret=='CA') $ret = 'California'; return $ret; } header('Content-type: text/plain'); echo preg_replace_callback('/##(\w+)?_(\w+)##/','my_vars',$msg); ?> Output: Told ya simple