php

Efficiency of using a function to output html tags in php

Trying to come up with a basic way to display code in a way that would be nicely maintainable, I thought of doing something like this: echo htmlfunction('a',array('href'=>'http://google.com'),'google'); to generate: <a href="http://google.com"&gt;google&lt;/a&gt; this would use as a global scale function to output all html tags. th...

[solved] PHP trouble with concurrent sessions and AJAX

I have a session handler class that calls session_write_close() at the end of the script. This insures that even if a header() or exit() is issued the session data is saved. public function __destruct() { session_write_close(); } However, I have noticed that for one of my AJAX pages TWO session updates are committed by the databas...

How to stop PHP source from being printed to my browser?

I just downloaded this "PHP Code Snippet Library" scrpt from http://www.sourceforge.net/projects/php-csl/ , when I try to run it from my local dev server, all the PHP on every page is output as PHP code, instead of compiling and running the code it seems to show the source of the PHP to the screen. I have never had this happen before, h...

how do I stop further methods in a PHP class?

I am learning OOP with PHP. I am creating a class to extract XML data from a website. My question is how do I stop the given object from executing more methods if there is an error with the first method. For example, I want to send the URL: class GEOCACHE { public $url; public function __construct($url) { $this->url=$url...

Replace some strings in PHP with regex?

I need to do a simple regex find and replace with PHP for my syntax highlighting script in PHP. I need to take a string of code which will actually be a whole php file that is read into a string like this. $code_string = 'the whole source code of a php file will be held in this string'; And then find all occurences of these and d...

what does Parse error: syntax error, unexpected '"' in /home/XXX/public_html/feedback2.php on line 180 mean?

and how do I find where line 180 is in the code ? I'm trying to create a PHP feedback form scrip ...

CakePHP saveAll() function problems

Hi GUys, Im trying to save a record to a table aswell as an accociated record. The main table is called quotes and it has a hasmany link to the table quote_items. quote_items belongsto quote When i try and save it saves the record in quote but does not save the record in quote_items . Below is my quote add function function add(...

can not use file_get_contents of dyanmically created location

I am trying to use file_get_contents() to get the html from a page. the following works great: file_get_contents('http://www.mypage.com?Title=Title') but the following causes an error: $Title = 'Title'; file_get_contents("http://www.mypage.com?Title=$Title") The error is: Bad Request Your browser sent a request that this server co...

preg_match pick url from other site

Hi , i want to pick all directory url from this site,Click Here i did the pregmatch, but it retrieve entire site URL,means unnecessary url links also rendering , Here is my code My code So finally what i want is , i want all submission link from that site.... ...

Is there anything like Python's ctype for PHP? Accessing libraries without the need to write an extension?

Python has ctypes to access libraries. In PHP you write extensions for everything. Popular extensions like the one for libgd are available almost everywhere. Is there any extension which works like Python's ctypes, letting you access libraries without the need to write an PHP extension? ...

PHP $_FILE array missing entries from submitted HTML form

Hi, Basically when I have more than about 25 file uploads in one form, the PHP $_FILES array is cropped to the first 25 entries (0-24), which is incorrect. It should have all 31. This only happens on one particular server. Apache with PHP. I’ve tried it on two other servers and they seem to allow all 31. Could this be caused by some co...

simple paging with PHP

Hi, I would like to implement paging in PHP. I have some result set from db, let it be an array. I need a paging that should display 4 records per page and the page numbers should be of the following "<< 1,2,3.....20 >>" and when you select page 2, then the format should be of the following "<< 3,4,5.....20 >>" can you guys sugges...

Why will this text in the browser source code not show on the screen?

I am modifying an existing source code viewer script in PHP that I found on the web. It is to store source code in a nice category fashion. I am having a problem now though. Below is a screen shot of me viewing the source code in Firefox, you can see the part that is supposed to show on the screen but for some reason it is not showi...

Template extraction in python/php

Are there existing template extract libraries in either python or php? Perl has Template::Extract (http://search.cpan.org/%7Eautrijus/Template-Extract-0.40/lib/Template/Extract.pm), but I haven't been able to find a similar implementation in either python or php. The only thing close in python that I could find is TemplateMaker (http:/...

underscores in php function calls

I know that underscores in function names in PHP is used to "implicitly" denote that they are supposed to be private...but I just saw this code: class DatabaseConnection { public static function get() { static $db = null; if ( $db == null ) $db = new DatabaseConnection(); return $db; } private $_handle = null;...

Fix links addresses on websites HTML code

Hello, i have been working on one tool lately. It grabs all the link addresses from the website. My problem is that links in html code sometimes is different: /index.php index.php http://www.website.com/index.php I need to make all links same: /index.php -> http://www.website.com/index.php index.php ...

differece between for loops in Java and foreach loop in PHP

In PHP we use.... foreach ($array as $value) { echo $value; } In Java the same thing can be done using for (int e : array) { System.out.println(e); } is there any difference between the above 2 code segments ...

PHP/MySQL How do I remove duplicate information from a LEFT JOIN?

I am trying to generate a simple list from a series of tables in a MySQL database. The SQL I am using is: $resource_sql = "SELECT prod_spec_sheets.spec_uri, prod_spec_sheets.spec_title, prod_photos.photo_uri, prod_photos.photo_title, prod_diagrams.diag_uri, prod_diagrams.diag_title, prod_ies.ies_uri, prod_ies.ies_title, prod_instruc...

Secure Token Process

Im currently in the mist of developing a website using PHP and MYSQL. Its a private website therefore registrations must allowed using emails. In simple tearms if a new user has to be registered. The administrator has to go into the system and add an email address to be registered. What i want to create is a token or a pass value when t...

PHP HTML E-Mail Character Issue

Every time i use this script i get random symbols appear in the email. Is it the character type in the headers. If so what are the correct character type to use? $icontent = nl2br($icontent); $str = "<html>"; $str .= "<head>"; $str .= "<title>Mail</title>"; $str .= "<style type='text/css'>"; $str .= "<!--"; ...