php

Upload size problem in PHP and MySql

Hi! I am uploading files to a MySql DB through PHP. I am able to upload files upto 1MB size (found out by trial and error). Files greater than 1 MB in size are not getting uploaded. The MySql error printed by mysql_error() function in PHP is: MySQL server has gone away Can anybody please help me with this? The MySql server is up and ru...

How can I insert this block of html into a page from a json response with jquery?

<script type="text/javascript"> var dataString2 = 'run=captchagood&comment=' + comment; $.ajax({ type: "POST", url: "process.php", data: dataString2, dataType: "json", error: 'error', success: function (data) { if (data.response === 'captchasuccess') { $('div#loader').find('img.load-gif').remo...

When to use static modifier in PHP

Doing some code reviews lately I came across a number of classes that have significant number of static methods in them... and I can't seem to grasp why? Hence my question: What are the best practices regarding using static methods in PHP? When would one want to use them and when would one shouldn't use them? What are specific differe...

To understand queries in PHP PG -prepared statemens

How do you read the following code about pg_query_params and pg_prepare? $result = pg_query_params ( $dbconn, "SELECT flagged_for_moderator_removal // unsure about Repetition here FROM questions WHERE question_id = $1", array ( $_GET['question_id'] ) ); if ( pg_num_rows ( $result ) == 0 ) { $resu...

web based application server Implementation

I intend to create a web based application server. The server is implemented in C and I wish to create a web based interface instead of a specific client application. Could anyone please suggest what approach/technology I can use to implement ? Thank you. -Mac ...

Php: How to calculate Adler32 checksum for zip?

I'm using a combination of Paul Duncans php ZipStream (http://pablotron.org/software/zipstream-php/) on the server side, for on-the-fly creation of zips, and Fzip (http://codeazur.com.br/lab/fzip/) on the Flex/Air client side. Works fine in Air, but when running Flex in browser, the zip needs to include a Adler32 checksum in the header ...

PHP function to reorder an array

Here is a sample array of all external JS files from paypal.com: Array ( [src] => Array ( [1] => https://www.paypalobjects.com/WEBSCR-590-20090814-1/js/lib/min/global.js [2] => https://www.paypalobjects.com/WEBSCR-590-20090814-1/js/tns/mid.js [8] => https://www.paypalobjects.com/WEBSCR-590...

PHP htmlspecialchars error

why would this $trader_details = array_walk($trader_details, 'htmlspecialchars'); give this error? Severity: Warning Message: htmlspecialchars() expects parameter 2 to be long, string given afaik htmlspecialchars only has optional parameters apart from the input string? this running in codeigniter thx ...

javascript function not get called when arguments from php

I am running the < a > tag in php. Whenever I pass an argument in js function it does not get called but if i pass empty arguments, the function gets called. js: function displayBigImage(img){ alert("inside func"); } php: //NOT WORKING: echo "<a href='javascript:displayBigImage('".$row['IMG_ID']."')'>Press</a>"; //WORKING: echo "...

Am I correctly supporting UTF-8 in my PHP apps?

I would like to make sure that everything I know about UTF-8 is correct. I have been trying to use UTF-8 for a while now but I keep stumbling across more and more bugs and other weird things that make it seem almost impossible to have a 100% UTF-8 site. There is always a gotcha somewhere that I seem to miss. Perhaps someone here can corr...

Browser crashes when about around 4 million records entered in MYSQL.

hello all I downloaded a database that was exported to the TXT format and has about 700MB with 7 million records (1 per line). I made a script to import the data to a mysql database, but when about 4 million records inserted into, the browser crashes. I have tested in Firefox and IE. Can someone give me an opinion and some advice about ...

PHPTAL and nested templates. Possible?

I've been playing around with PHPTAL for the last couple of days. Overall I really like it. It's been much easier to get into than most others I've looked into. I am having one particular problem, though. Here's the issue. I am trying to nest two templates. Let's say InnerClass has this template: <div>Hello World!</div> OuterClass ha...

Anyone know of a decent HTML editor?

I have always used a text-editor for my web-projects, but as they get more complicated, some kind of help is pretty much necessary. I need something that will do the following: run on linux be as close to just a text-editor as possible (I use gedit for everything) keep track of object attributes, possibly standardizing the order (i.e. ...

Ternary operator and string concatenation quirk?

Hi I just want to know why this code yields (at least for me) an incorrect result. Well, probably i'm in fault here $description = 'Paper: ' . ($paperType == 'bond') ? 'Bond' : 'Other'; I was guessing that if paperType equals 'Bond' then description is 'Paper: Bond' and if paperType is not equals to 'Bond' then description is 'Paper...

PHP Function to get difference element from both arrays

Here's the situations: I have 2 arrays, eg: $a=array('a','b','c','d'); $b=array('1','b','c','e'); I want to produce 2 arrays with result: $c=array('a','d');//only element appeared on $a $d=array('1','e');//only element appeared on $b Do you have a clever solution? ...

Cookie value is not being retrived properly

Hello All, I am setting a cookie in a PHP script which also has some html , the first line is setcookie function as required. <?php setcookie("user", "xyz", time()+3600); ?> <html> ------ some html tags </html> In other PHP script where am trying to access , i get a blank value . $user=$_COOKIE["user"]; Can anyone tell me why is...

Sitemap for dynamic content?

I am developing a webapp using codeigniter (mvc) and php. I was wondering how do I create a sitemap for search engines when my contact is dynamic? Are there best practices for this, or is there a way to automate the process? I ask because content will be constantly and rapidly added so I'd like the sitemap be recent. Thanks Update: to...

Dynamic urls / MVC

Let's say my main controller 'hotels' has a pattern for the url, such as: /hotels/colorado/aspen/hotel-name/ How should I program my controller ( keep in mind I'm still learning MVC ) to handle this variable? I know that I have to probably check if anything after /hotels/ is set, otherwise show the default hotels page. If a state is s...

PHP count amount in array with a given value

Say I have an array like this: $array = array('', '', 'other', '', 'other'); How can I count the number with a given value (in the example blank)? And do it efficiently? (for about a dozen arrays with hundreds of elements each) This example times out (over 30 sec): function without($array) { $counter = 0; for($i = 0, $e = co...

Sending email by jQuery / PHP

How can you send an email by jQuery and PHP if the user flags a question? My JS code in HEAD jQuery('a.flag_question').live('click', function(){ jQuery.post('/codes/handlers/flag_question.php', { question_id: jQuery(this).attr('rel') }); alert ("Question was reported....