php5

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 ...

ERROR: duplicate key violates unique constraint "search6_idx1"

I'm trying to insert items into my postgres table via PHP But get the following error message ERROR: duplicate key violates unique constraint "search6_idx1" search6_idx1 is the index table for search6. I tried the following select setval('search6',45) and somehow that only works for sequences. Is there any way to solve this error? ...

Doctrine override relation accessor

Hi everybody, I'm using Symfony 1.4 + Doctrine 1.1. I have a schema with a one-to-many relation. Let's say A has many B, I ask for all the B's of A as follow: $a->b This returns a Doctrine_Collection. What I want its a way to tell doctrine to give me all the B's of A sorted by a particular attribute of B. I don't want to re-write th...

mysql - search between dates where all dates appear

I'm working with some imported data that stores details about whether a "room" is available on a specific day or not. Each room has an individual entry for the date that it is available. | id | date | price | -------------------------------- | 1 | 2010-08-04 | 45.00 | A user can search across a date range and the sea...

wordpress .htaccess with permalinks

I have a permalink working but as soon as I create a post it tells me that soory post not found permalink setting is to "/%pagename%/" and here is .htaccess: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /ryan/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d R...

PHP - parse a value outcome to HTML

Hello, I want to use something like this in a PHP file: $about = array ('dutch' => 'over', 'spanish' => 'sobre', 'english' => 'about'); if ($USER['lang'] == 'dutch'){ // $about - becomes 'over' } elseif ($USER['lang'] == 'spanish') { // $about - becomes 'sobre' } else { // $about - becomes 'about' } And transfer the outcome to...

PHP upload and resize image

Hello world I am working on a script that uploads a picture using PHP and I wanna make it resize the image to width 180 before saving it. I tried using the WideImage library and ->saveFileTO(...) but when I include the WideImage.php in the page, the page goes blank !! So here is my script if you can help me and tell me how to make it sav...

Help in securing simple email contact form

Hey guys, I have very basic php skills. As it stands, I'm trying to "reverse" engineer a contact form I found line that has some level security (I truthfully don't know how good it is). I think I got it, it works, but I just thought maybe some of you more experience in php can glance it over and see if it's actually still secure. As I s...

What's the best way to access a URI variable after a hashtag from php?

I have javascript updating my URI as below: /index.php?page=list#page=news But I would like to make page=news accessible somehow from my server so that when the URI is copied and pasted, it would go to the news page. What is the best way to do this ? I tried $_SERVER['REQUEST_URI'] but everything stored in $_SERVER is before the hash...

Looking for a PHP Event Calendar solution.

Hi, I am looking for a PHP event calendar solution for my current website. Where can I find some php5 OOP event calendar script tutorial? Or I should learn the Google Calendar API? Which one is better? I plan to use Kohana now. But I can only google little resouce about it. thanks. ...

Pass php object to smarty

I have an issue with passing an object to smarty tag. I have the following code: $contact = new Contacts; $smarty = new Smarty; $smarty->assign('contact',$contact); In test.htpl : <html> <head> <title>{$title}</title> </head> <body> id: {$contact->id} <br/> name: {$contact->name} <br/> email: {$contact->email} <br/> ...

PHP include_once not working for file in parent directory

I just started working on a site that has been passed down to me that isn't working. I've found that there's a problem when in /admin/index.php it tries to instantiate an instance of /classes/admin.php. However, if I copy /admin/index.php to /admin-index.php, it can instantiate the class just fine. Also, if I move /classes/admin.php into...

Hide value from unregistered user

Hello all! Could you all give me an idea on how can i hide a specific value from an unregisted user? But once a user logins, that value should be visible? Thanks :) ...

Combine/Concatenate MP3s on Server Using PHP

I have a site that will be hosting small MP3 files. I want to create a utility that will allow me to combine the mp3 files together to create a single MP3 file. I'm somewhat new to PHP but not new to programming. Ideally, I would have a function that let me specify the a starting file and then append the second file to the existing fi...

Show png file on Web page

All, I am executing a PHP script through CURL which returns a PNG file as an output. How can I show the png file in a php web page? ...

pchart stroke function

The call to Stroke() function in pChart renders an Image. When I try to display this image on the browser, it shows something like the following instead of showing an image. How can I display the image instead of these wierd characters? �PNG ��� IHDR����������h����tRNS������7X}�� �IDATx���wt[Y~'���C H�Q�(�RV)TUW��v�}��cό�9�;g�xvv�;s�...

pChart - Display png image on browser

I am using the pChart class library to display .png Image on the browser. Through AJAX, I call the controller action graphgenerator to call generateGraph function in a model and display the output through a view on the browser. The generateGraph function in the MVC model, tries to generate graphs in a loop with an HTML table using pChar...

How to exclude .png files from being rewritten via htaccess.

I have the following rule that redirects all traffic to index.php when public folder is visited. How can I modify it to exclude .png files? That means, if /public/something.png is visited, it should render in the browser or should be accessible inside the code when called using an: "<img src='/public/example.png'>". RewriteCond %{DOCUM...

imagepng - creating in /public folder

How can I specify filepath to imagepng function? It always seems to create the file in "/public" folder when used in an MVC Zend Framework and even when an explicit filepath is supplied. Is it because of the rewrite rules I have? My .htaccess rewrite rules are as under: FileETag none <IfModule mod_expires.c> ExpiresActive On ExpiresDefa...

How to get a whole number value from a variable in php?

The following is my code, $da =01; $cal_sunday = $da + 7; echo $cal_sunday; the above calculation return the output as '8'.. i need the output as '08'... help.. ...