php

Passing PHP variable to Javascript dynammically added textbox

hello i have a javascript function like this: function addfamily(divName){ var newdiv = document.createElement('div'); newdiv.innerHTML = "<input type='text' name='family[]' size='16'>"; document.getElementById(divName).appendChild(newdiv); } which dynamically adds textbox to the form and a php script like this: <?php $...

Check if a string contains a certain number

I have a string 8,7,13,14,16 Whats the easiest way to determine if a given number is present in that string? $numberA = "13"; $string = "8,7,13,14,16"; if($string magic $numberA){ $result = "Yeah, that number is in there"; } else { $result = "Sorry."; } Looking for magic. ...

Posting with snoopy using proxy takes too long

Hi I have a php script which tries to do a post. I use Snoopy class and also I use proxy. I managed to post but when I use a proxy the posting is extremely slow. I mean it can take till 30 minutes. I don't want to block my script for 30 minutes waiting for a post. Any idea how could I solve this? The code looks like: require('../includ...

Transaction Processing Using PHP and MySQL

Hi, I'm trying to implement two-phase commit using PHP and MySQL, and coming up short. The main block I've found is that I'm unable to store the MySQL connection resource in a place where I can find it again for the second phase. Is it possible to serialize a database handle? Here's the case I'm trying to code for: User sends data Se...

Extracting info from html using PHP(XPath), PHP/Python(Regexp) or Python(XPath)

I have approx. 40k+ html documents where I need to extract information from. I have tried to do so using PHP+Tidy(because most files are not well-formed)+DOMDocument+XPath but it is extremely slow.... I am advised to use regexp but the html files are not marked up semantically (table based layout, with meaning-less tag/classes used every...

How to internationalize string used in javascript code?

While developing AJAX program, I met the design decision to make string I18N in JavaScript.code. Some string is only used by JavaScript. For example. $('#submit').click(function() { $(#target).html('Please wait while submitting...').load(someURI); } I'd like to I18N the string 'Please wait while submitting...'. I'm not sure what's...

Compare array attributes

I would like to compare two array items with php, I think I should use array_intersect_key but I don't know how I can do that. Array 1 [1] =&gt; obj Object ( [idobj:protected] =&gt; 2 ) [2] =&gt; obj Object ( [idobj:protected] =&gt; 1 ) Array 2 [1] =&gt; obj Object ...

Accessing HTML inside XML using SimpleXML in PHP

Hi, I'm having a problem with SimpleXML. When I'm using the children() method to get the contents of an XML element, with elements that contain HTML, it will parse the HTML contents as XML. How would I make it so that it won't parse HTML? ...

'Undefined' Notice while populating arrays

While populating an array with data from a SimpleXML call, PHP throws exception to what it believes as 'Undefined' keys, however, the output is actually correct. $doc = new SimpleXmlElement($http_result, LIBXML_NOCDATA); $result = array(); $x = 0; foreach($doc->users->user as $item) { $result['user'][$x]['id'] .= $item->id; $...

Upload files using list box in PHP

Hi all, I want to upload files from a list box in php. I am able to do it by using <input type="file"> which I found on http://www.tizag.com/phpT/fileupload.php But when I change this <input type="file"> by <select> i am trying this way <form enctype="multipart/form-data" action="upload.php" method="POST"> <input type="hidden" name...

The best PHP IDE , for pentium 3 , CPU 667 MHz , DDR 256 mb

What is the best , PHP IDE , for pentium 3 , CPU 667 MHz , DDR 256 mb ,the operating system is Windows 2000 Professional , that can run very fast , and have a php debuger , and easy to work :). Thx ! ...

Unique entries in an array

Hi, I have the following that stores the previous 10 URL's into a session: function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pag...

PHP - Bug in polygon GD library?

Hi guys, I have run into some trouble with the gd library's imagefilledpolygon(). For some reason some of my lines were ending up 1px out of place so I decided to debug it using imagepixelset to set the colour of my shapes points to red. if you look at the picture you can see some of the points are inside the shape ... some are outsi...

copy file from one folder to other

I want to move all files from one folder to other. my code is following in this i made a folder in which i want to copy all file from templats folder $doit = str_replace (" ", "", $slt['user_compeny_name']); mkdir("$doit"); $source="templat/"; $target=$doit."/"; $dir =...

Mantis - Integrate Wiki

I am using Mantis (PHP and MysQL) as a bug tracking tool and I would like to extend it in order to document requirements and technical specifications. Ideally, I should be able to link a defect with a requirement. Is there a way to integrate a Wiki tool (preferably PHP and MySQL based) into Mantis? EDITED: Instructions how to integra...

Parsing Javascript (not JSON) in PHP

I have a php string containing the serialization of a javascript object : $string = '{fu:"bar",baz:["bat"]}'; The actual string is far more complicated, of course, but still well-formed javascript. This is not standard JSON, so json_decode fails. Do you know any php library that would parse this string and return a php associative arr...

Loading XML in php giving error

Hi All, I am trying to load xml in php $doc = new DOMDocument(); $doc->load("LoginVal.xml"); I am getting an error as Warning: domdocument::domdocument() expects at least 1 parameter, 0 given in C:\Program Files\Apache Group\Apache2\htdocs\hello.php on line 5 Fatal error: Call to undefined method domdocument::load() in C:\P...

How to check using PHP FTP functionality if folder exists on server or not?

Is there a way to check if a a folder exists on the server using PHP Ftp functionality? ...

MySQL Deadlock Detection via PHP

What is the best-practice in dealing with MySQL Dead-Locks in PHP? Should I wrap all database calls in a try{}catch{} block and look for the DeadLock error code from the database? Do I then reissue the whole transaction again (I presume the one that failes rolled back)? ...

What are some shorthand (but not neccessarily safe) ways of displaying arrays in PHP?

I have tried to do this: <?=implode(array('A','B','C')); To display an array but was wondering if there was an easier way of showing an array? I tried <?=print_r(array('A','B','C')); But it actually displays an array structure. I want the string to be like ABC. ...