php

Translate a webpage in PHP

I'm looking to translate a webpage in PHP 5 so I can save the translation and make it easily accessible via mydomain.com/lang/fr/category/article.html rather than users having to go through google translate. I've found various easy ways to translate text via CURL, however what i'd really like to be able to do is translate an entire webp...

Allowing Google to bypass CAPTCHA verification - sensible or not?

My web site has a database lookup; filling out a CAPTCHA gives you 5 minutes of lookup time. There is also some custom code to detect any automated scripts. I do this as I don't want someone data mining my site. The problem is that Google does not see the lookup results when it crawls my site. If someone is searching for a string that i...

zend form multicheckboxes naming

how do i have to nest multicheckboxes so that they are named like this 'foo[]['bar']' . i've used subforms but they give me naming like this 'foo[bar][]'. my code: $sub = new Zend_Form_SubForm('sub'); $wish = new Zend_Form_Element_MultiCheckbox('bar'); $wish ->setMultiOptions($education_direction->getAll()) ->setLabel('W...

Can I use javascript regular expression in php as it is.

I am using a regular expression in javascript and want to do server side validation as well with the same regular expression. Do i need to modify it to make it compatible or will it run as it is. How to use PHP regular expresion. Please provide a small example. Thanks in Advance EDIT For Email Validation var pattern = new RegExp(/^(...

php-mysql error while inserting into table

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 ...

php: shortcut to writing this?

what would be the shortest way to write this? if(strpos($haystack, $needle)!==false){ $len = strpos($haystack, $needle)+strlen($needle); }else{ $len = 0; } I remember that I saw some shortcut somewhere for this that checked and set a variable at the same time. ...

Good Guide For Web App Security?

Hello! I am pretty good on making web applications and I know how to transfer data to and from client/server, etc. I need some help though learning how to make the data exchanges more secure. That is the reason why I feel kind of scared to publish any web app I make. I wanted to know what are some good guides to help you understand and l...

MVC: Model View Controller -- does the View call the Model?

I've been reading about MVC design for a while now and it seems officially the View calls objects and methods in the Model, builds and outputs a view. I think this is mainly wrong. The Controller should act and retrieve/update objects inside the Model, select an appropriate View and pass the information to it so it may display. Only cr...

problem creating jpg thumb with php

Hi, I am having problems creating a thumbnail from an uploaded image, my problem is (i) the quality (ii) the crop http://welovethedesign.com.cluster.cwcs.co.uk/phpimages/large.jpg http://welovethedesign.com.cluster.cwcs.co.uk/phpimages/thumb.jpg If you look the quality is very poor and the crop is taken from the top and is not a res...

mySQL removes first digit

Hi guys, I am inputting data into a mySQL database via a PHP script, but for some reason when I check the database, all of the phone numbers have their first digit removed, like so, 0123456789 shows up as 123456789 in the database, but if I change the data type from INT to TEXT, it shows correctly, I am very hesitant to keep it as TEXT t...

Deleting a specific item by using array_splice/array_slice in PHP

How do I delete a specific item by using array_splice/array_slice in PHP? for example: array('a','b','c'); how to just delete 'b'? so the array remains: array('a','c'); Thanks ...

On uploading php page, it is giving warning. Error seems to be of session related

Error I tried this page to run on local, it is running perfectly fine but showing me a warning on uploading. What might be the reason. I used session as per given in w3schools.. The session_start() function must appear BEFORE the tag ...

Is there a MySql implementation of OAuths SimpleOAuthDataStore?

Hi, I've recently been using OAuth to secure resources on my server. The distribtion comes with SimpleOAuthDataStore.php. However I was wondering if anyone knows of a MySql implementation of this (in PHP)? Thanks Rich ...

Java gzip.read and PHP fread() gives different results

I have line in Java and in while I get number: i = gzipinputstream1.read(abyte0, j, 4096); From while number: 959 1552 1577 1617 1680 when I want use in php: $i = fread($handle, 959): while return: 959, 959, 959, 5 How make that in PHP result will be the same? ...

PHP + GD: imagetruecolortopalette not keeping transparency

I am using GD to output an image that is a truecolor+alpha channel PNG file using imagepng just fine. However, I would like to have the ability to also output an ie6-compatible 256-color PNG as well. According to the official documentation for imagetruecolortopalette: The code has been modified to preserve as much alpha channel inf...

jquery - access json data from php

I have a problem accessing JSON data. I'm new to JSON an jquery so there is probably a easy solution to it and i would be glad to find out. My jQuery: $.post( "currentPage.php", { 'currentPage': 1 }, function(data){ $("body").append(data); } ); currentPage.php: $returnArray['left'] = 'test_left';...

Invalid argument supplied for foreach()

Hi, I've got a code that echos out every row of the database with a checkbox next to it. $result = mysqli_query($database, "SELECT * FROM $imei_to_look_for" ); while ( $row = mysqli_fetch_array($result) ) { echo htmlspecialchars($imei_to_look_for). "<input type='checkbox' value='$row[event_number]' name='todelete[]' />"; and another,...

Jquery Serialization not working

Have a simple form (only extract fields here) but for some reason the JQserilization is not working; looks fine in alert() but only the first form field gets posts. Suggestions please - thanks in advance Form: <form id="neweventform" method="post" action=""> <div class="grid_4 alpha">Setup date *</div> <div class="grid_7 omega"> <sele...

Generate colour palette from an image

Just for fun I've been looking at how to use the GD library to create a colour palette from an image. So far I've used GD to resize a user uploaded image to an appropriate size for displaying on a webpage. Now I'd like to be able to get about five or so different colours from the image that represent the range of colours present in it. ...

define keys in multidimensional array from csv

I want to compare two arrays, one coming from a shoppingcart and the other one parsed from a csv-file. The array from the shopping cart looks like this: Array ( [0] => Array ( [id] => 7 [qty] => 1 [price] => 07.39 [name] => walkthebridge [subtotal] => 7.39 )...