-
Passing in versus global reference
Date: 12/11/07
Keywords: no keywords
Are there any benefits to passing variables into a query versus referencing them via global? Ignore coding standards and efficiency in this case.
Source: http://community.livejournal.com/php/602380.html
-
Dream Weaver Issues
Date: 12/11/07
Keywords: php, browser, css, html
Hello,
Up till recently, the company I work at has built PHP applications by first writing static HTML pages from scratch and then rigging them up with enough PHP code to satisfy the short-term requirements of the project. This is fine for very small projects, but it just doesn't scale well. Up until I arrived at the company, all HTML/CSS and PHP was written in Dream Weaver, and all applications were built to display properly in Dream Weaver as well as in a browser.
I am trying to adopt the use of PHP MVC frameworks, but I am running into problems with Dream Weaver. Dream Weaver practically expects to be working on a somewhat primitive architecture where the URL structure of a site is directly derived from the directory structure of the files on the filesystem.
Has anyone here successfully configured Dream Weaver to play nicely with Cake, Symfony, or any other frameworks that make heavy use of URL rewriting and dynamically assembled pages?
Thanks
Source: http://community.livejournal.com/php/602134.html
-
mail
Date: 12/09/07
Keywords: rss, database
My mail script has gotten rather long and complex, so I'd like to move the code off of each page that requires an email to be sent.
I've thought about using an include, but I want something cleaner. My emails are a standard template, just notification that a change has been made. The only difference is who the email gets sent to.
This is where my novice will show ... what I want is the ability to put just one line on the page something like ...
mail2user($emailaddress)
I'd pull the email address from my database as the script runs and the "mail2user" would know to pass the $emailaddrss variable to that "function"???
Is this possible?
Source: http://community.livejournal.com/php/602053.html
-
stopping iFrames from loading automatically
Date: 12/07/07
Keywords: php
Hi, I'm trying to stop iFrames from loading until a user clicks on a link to expand a div. I want to include 10+ iFrames with custom PubMed search result scripts in them on one page, but that results in an unacceptable load time. Is there an easy way to stop iFrames from loading their sources automatically? I'm creating an extensive, integrated ADHD research/news page based mostly on PHP at the request of a clinical psychologist in Minnesota... we would appreciate your help.
Shawn
Source: http://community.livejournal.com/php/601788.html
-
preg_replace help
Date: 12/06/07
Keywords: no keywords
How would a RegEx look to parse a string and replace a line like the following.
Original:
• U.S. District Court for the Southern District of New York
New:
- U.S. District Court for the Southern District of New York
And the ending BR tag is optional. Thanks.
Source: http://community.livejournal.com/php/601458.html
-
Preventing SQL Injection
Date: 12/04/07
Keywords: php, mysql, sql, security
I've been trying to understand, SQL Injection ... and reading this.
http://www.phpbuilder.com/columns/ProPHPSecurity_excerpt_part3.php3
$sql = "INSERT INTO table
(unit1, unit2, unit3, unit4)
VALUES
(\"$value1\", \"$value2\", \"$value3\", \"$value4\")
";
mysql_query($sql,$conn) or die(" Error 1: ".mysql_error());
This is my standard update query. Being new to PHP, and even less knowledgeable of MySQL what makes that string open to attack?
Source: http://community.livejournal.com/php/601327.html
-
Optimise me!
Date: 12/01/07
Keywords: no keywords
This looks repetitive, anyway to make it better?
$arr_bits is basically a date (exploded at '/' from YYYY/MM/DD/).
if (!empty ($arr_bits[2])) {
$this->minTimeStamp = mktime (0, 0, 0, $arr_bits[1], $arr_bits[2], $arr_bits[0]);
$this->maxTimeStamp = mktime (23, 59, 59, $arr_bits[1], $arr_bits[2], $arr_bits[0]);
// If there's no day but there is a month, get the first and last second of the month
} elseif (!empty ($arr_bits[1])) {
$this->minTimeStamp = mktime (0, 0, 0, $arr_bits[1], 1, $arr_bits[0]);
$this->maxTimeStamp = mktime (23, 59, 59, $arr_bits[1], date ('t', $min_timestamp), $arr_bits[0]);
} elseif (!empty ($arr_bits[0])) {
$this->minTimeStamp = mktime (0, 0, 0, 1, 1, $arr_bits[0]);
$this->maxTimeStamp = mktime (23, 59, 59, 12, 31, $arr_bits[0]);
}
Thanks ^^;;
Source: http://community.livejournal.com/php/600874.html
-
Variable Functions w/ Unknown number of arguements
Date: 11/30/07
Keywords: no keywords
Suppose you have a function called like this:
$obj = new $class();
$obj->$function();
Now suppose you want to pass the function a number of parameters from 0 to n inclusive. Is it possible to pass the function an unknown number of parameters, provided that the parameters are stored in array, where array[0] is the first parameter, array[1] is the second, and so on?
EDIT: Solved
There's a function call_user_func_array that allows you to call a variable function with an array for parameters. Unfortunately, it doesn't work on $obj->$function
.
However, for some reason (couldn't find the explination), setting the object and function in an array as the first parameter works.
call_user_func_array(array($obj, $function), $args);
Source: http://community.livejournal.com/php/600798.html
-
preg_replace quandry
Date: 11/30/07
Keywords: web
I'm trying to remove any of the below hyperlinks that do not contain "video/" or "print/" in the href attribute. However, I cannot figure out what else to put into the expression so it works.
$text = '
View Winning Marketing Material
View Winning Website
View Winning video
';
echo preg_replace('/[^<]*?<\/a>/', '', $text);
Source: http://community.livejournal.com/php/600508.html
-
RegEx Stoopid
Date: 11/29/07
Keywords: no keywords
I am having a world of difficulty trying to come up with a RegEx that will remove hyperlinks from text ONLY if a list of safe words aren't found. Example:
Safe word - "news,cars,apples,etc"
- This hyperlink would be removed
- This hyperlink would be ignored
Source: http://community.livejournal.com/php/600054.html
-
when you need a hammer, use a hammer
Date: 11/28/07
Keywords: spam
I have a form that people have been trying to spamalot, so I thought hmm some bad words should never show up in certain places, so if they are there it has to be spam.
Here is what I have:
$bad_words = array('href','http','url');
if (in_array($foo=$_POST["name"], $bad_words, true)){
die ('SPAM not sent');
exit;
}
if (in_array($foo=$_POST["company"], $bad_words, true)){
die ('SPAM not sent');
exit;
but I would get "parse error, unexpected T_BOOLEAN_OR in form on line" that had this:
if (in_array($foo=$_POST["name"], $bad_words, true))||(in_array($foo=$_POST["company"], $bad_words, true)){
and I do not know why (other than its been a long day and cant see strait).
Any hints?
Source: http://community.livejournal.com/php/599664.html
-
DomDocument->Load() & DomDocument->Save()
Date: 11/28/07
Keywords: xml, security
I need in Load and Save of XML-documents on disk.
I use DomDocument for work with them.
And I’m interesting, what about shared access security?
Does DomDocument do flock() for reading/writing files?
Or will it better if I read and write XML-files by myself and do LoadXML()/SaveXML()?
Source: http://community.livejournal.com/php/599416.html
-
It's a good day (for once in the IT lab)
Date: 11/28/07
Keywords: no keywords
It's been one of those weeks when everything has metaphorically been on fire.
I'm working on a temporary script to resolve a problem from last week and got the chance to write this oh-so-Internet-kiddy influenced code.
function YslashN ( $var )
{
return ( $var == 1 || $var == true ) ? "Yes" : "No" ;
}
Source: http://community.livejournal.com/php/599148.html
-
PHP5 Still Not Enabled for mySQL
Date: 11/27/07
Keywords: php, mysql, html, sql, apache
This is an update from this post last week. So far, I've had no luck with it. To recap my config settings:
PHP 5.2
Installed on Windows XP, C:/php
php.ini file copied to c:/windows/system32
doc_root = "E:\public_html"
extension_dir = "C:/php/ext"
extension=php_mysql.dll uncommented
Apache 2.2.4
Installed under C:/Apache
php5 running as a module
document root, E:\public_html
System | Windows NT CROSSBOW-DEV 5.1 build 2600 |
Build Date | Nov 8 2007 23:18:08 |
Configure Command | cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared" |
Server API | Apache 2.0 Handler |
Virtual Directory Support | enabled |
Configuration File (php.ini) Path | C:\WINDOWS |
Loaded Configuration File | (none) |
PHP API | 20041225 |
PHP Extension | 20060613 |
Zend Extension | 220060519 |
Debug Build | no |
Thread Safety | enabled |
Zend Memory Manager | enabled |
IPv6 Support | enabled |
Registered PHP Streams | php, file, data, http, ftp, compress.zlib |
Registered Stream Socket Transports | tcp, udp |
Registered Stream Filters | convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, zlib.* |
If I can't figure out anything else to get mySQL to work, does anyone have praise for Wamp?
Update
I was running out of time and just installed Wamp. It's almost too easy to configure and run. Thanks everyone for your input; it'll be very handy for future reference.
Source: http://community.livejournal.com/php/598969.html
-
RegEx filtering for comment box
Date: 11/26/07
Keywords: no keywords
I want to be able for user to add links, images, and flash to a platform I am building (Like MySpace or any other site does) but I want to make sure I clean the code well as I don't want to get hacked. Is there a place with all the RegEx expressions, etc that I could use as a guide to do this?
Thanks guys!
Source: http://community.livejournal.com/php/598779.html
-
Retrieving POST data from php://input
Date: 11/25/07
Keywords: php
Howdy,
I have wrote this script:
$max = $_SERVER[‘CONTENT_LENGTH’];
$fp = fopen(“php://input”, “rb”);
for($i=0; $i<$max; $i++) {
$ch = fread($fp, 1);
echo $ch;
flush();
ob_flush();
sleep(1);
}
fclose($fp);
It’s working right.
But I’m interesting in this: how script retrieving data from php://input? Does it get data directly from browser? Or does PHP retrieve it by itself and later send data to script?
Source: http://community.livejournal.com/php/598419.html
-
database and check boxes
Date: 11/25/07
Keywords: php
I'm making a site with a "preferences" page. The page will have mostly all check boxes.
[x] Email hidden
[x] last name hidden
... and so on.
In a previous post it was suggested that I not store each preference in its own colum but rather each users row gets a colum called preferences.
id userid pref
1 test1 yynynyyyn
2 test2 nnnnnynyy
My question what is the php function to pull those preference choices into each check box?
Source: http://community.livejournal.com/php/598121.html
-
File decryption + download = 100% CPU
Date: 11/24/07
Keywords: no keywords
Need your help guys!
We have the script that decrypts the file and sends it to the user:
----------------------------------------------------
header("Pragma: cache");
header("Content-type: application/force-download");
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".$this->getSize());
header("Content-disposition: attachment; filename=\"".$name."\"");
...
$bytes_number = 1024;
...
while ($bytes_already_read < $file_size) {
$bytes = fread($file_handle, $bytes_number);
for ($i=0; $i
But when I start a single download (~400 kb/sec) it freezes the server.
Apache starts eating 100% CPU.
What can you suggest?
Source: http://community.livejournal.com/php/597926.html
-
Can't get PHP5 to read mySQL
Date: 11/21/07
Keywords: php, mysql, sql, apache
I have PHP5.2 running under Apache 2.2 on Windows XP, and followed all directions to enable the mySQL library for PHP, but it's not working. Here's what I did:
Uncommented the extension lines for php_mysql.dll in c:php\php.ini
Enabled c:\php into the Windows PATH variable
Copied the mysql library DLL to windows/system32
Here is my phpMyAdmin config against this (Apache's port is 8080, also):
$cfg['Servers'][$i]['host'] = '127.0.0.1:8080';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'xxxxxx';
Any other pointers would be greatly appreciated.
Source: http://community.livejournal.com/php/597696.html
-
A High Tech Solution from a record label?!
Date: 11/20/07
Keywords: php, technology, web
Check out the new high-tech solution coming from record labels like BETA Records... did I say high-tech and label in the same sentence? Things are definitely a changing!!
BETA Records, in anticipation of their upcoming release of Version 3 (V3) of their online music social community, has created a technological innovation that could ultimately allow websites to become more dynamic, creative and sophisticated while enabling companies to cut costs and reduce loads on servers needed in large-scale clusters.
Called "BETACache," the new technology resulted from BETA’s PHP developers Rock Mutchler, Paul-Anton van Handel, Jon Bauer, Bernhard Schenkenfelder, and Eric Hollander.
Read more
Source: http://community.livejournal.com/php/597319.html