php

how to modify this php script to handle png and gif uploads

I have the following script (it looks long, but well commented). Problem is, i get errors when i try to upload a png or gif image. What can i do to adjust this (easy if possible) so that it can either work with png's and gif's or convert them before trying to work with them. This is the error that i recieve Warning: imagecreatefromjpeg...

How to setup nginx + php-fpm + wordpress for only certain URLs?

I'm trying to get nginx + php-fpm +wordpress to serve some pages from my site while acting as a proxy to other pages. ie: host/foo -> proxy to another www server host/bar -> wordpress (via fpm) the proxy part works fine, but the nginx -> wordpress part just keeps redirecting to the root page. When i strace the php-fpm process, i ...

IDE Duel -- Zend Studio 7 or Dreamweaver CS4

I'm developing PHP apps that leverage several frameworks (though not the Zend Framework yet...) and I make good use of Javascript (mostly jQuery). All mark-up is XHTML, of course, with CSS, etc. I'm looking to move beyond the beautiful simplicity of Notepad++. I'm using Windows Vista. I'm trying to decide between Zend Studio 7 or Dre...

To understand the validation of user's data for prepared statements

I read that you do not need to validate or sanitize user's input if you use prepared statements. This however does not make sense to me in the following example. The user gives his email address. I normally run this Validation code // to validate data if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { header("Location...

How can I split a mysql table into multiple tables and query the correct arrea?

Below is my friend table, I included 2 entries to show how it works, When a user adds a person as a friend it inserts 2 entries into the DB with this code; <?PHP //status 0=approved 1=declined approval 3=pending approval $sql = "insert into friend_friend (userid,friendid,status,submit_date) values ('$_SESSION[auto_id]','$frie...

Beginner if statement help

if ($row['active'] == 1) echo '<a href="prof?id=$id">'.htmlspecialchars($row['username']).'</a>'; else echo htmlspecialchars($row['username']); Could I write this shorter and cleaner somehow? ...

To have LaTeX-like PATH -system for PHP development

I develop my project at ~/Dropbox/db/. I need to move the folder continuously to /var/www to be able to see the result in Firefox because it is the only place where I have Apache. My filetree is at ~/Dropbox/db/ . |-- handlers | |-- login.php | |-- question.php | |-- question_answer.php | `-- register.php |-- index.php |-- form...

Reload Smarty Template with New Variables?

Hey all, I'm messing with using AJAX to fetch "partial templates" from the server and echoing them back to the browser. This will cause all this HTML to have to be sent back to the browser. I was wondering if there is a way to simply change the variables but leave all the html there. Something like this: $smarty->assign("fruit", "apple...

How to remove duplicated 2-dimension array in PHP?

I got some idea from the posts before are talking about making a hash value on for each $array[$i], and then compare the hash to get the unique array, but I don't know what exactly I can do. My sample array Data: $arr[] = array(0,1,2,3); $arr[] = array(4,5,2,1); $arr[] = array(0,0,0,0); $arr[] = array(0,1,2,3); I expected to return ...

PHP/SQL help with function

Help my write a function. function reportThread() { global $id; $result = mysql_query("SELECT is_checked FROM reports WHERE url = '?threadID=$id'"); $r = mysql_fetch_assoc($result); if ($r['is_checked'] == 0) { echo "<script type=\"text/javascript\">alert(\"A moderator has been notified.\");</script>"; mysql_query("INSERT INTO repo...

$_SESSION List in PHP

I would like to get session list from the localhost.So, I wrote session_start(); print_r($_SESSION); currently access person is two.one is from another PC and the last one is hosted pc.But the on shown only hosted pc session.Actually I would like to get all session user list. ...

Memcached extension for PHP on Windows Server

Hello, my configuration: Windows 2008 IIS 7 PHP 5.2.10 / FastCGI Memcache as a Windows Service I tried to use the php_memcache extension for PHP but it doesn't load. This extension comes with PECL 5.2.6 Any idea? Do you know if exist a php_memcache"d" extension for PHP on Windows? BR Santiago ...

dynamically scale images in php jpg/png/gif

Is there a simple way of dynamically scaling an image in php? Id like to specifically use some kind of function where i can insert it into my heml such as <img src=image.php?img=boss.jpg&width=500> and of course it would then scale the image to whatever height constrains it to 500px wide i appreciate all input, thanks. EDIT does ne...

PHP script doesn't work with // comments

I have a PHP script that doesn't seem to work when it contains a // type comment. I mean, the script just doesn't seem to execute beyond the // style comment. E.g. <?php header('Content-type: text/plain'); // some comment echo "OK"; doesn't work, no output. but: <?php header('Content-type: text/plain'); echo "OK"; does work. I se...

PHP - How can I find out if a value exists in an array when compared?

I have an array that looks like this: Array ( [0] => Array ( [0] => 1 [id] => 1 ) [1] => Array ( [0] => 2 [id] => 2 ) ) What I would like to do is compare an int value against what's in the id value field. So, if I were to pass in say a 1, I'd lik...

php image resize script dividing by zero

This was working a few moments ago, not sure what changed. error log reads [08-Aug-2009 02:09:20] PHP Warning: readfile(/images/32321249694312.JPG) [<a href='function.readfile'>function.readfile</a>]: failed to open stream: No such file or directory in /home/public_html/viewimg.php on line 82 [08-Aug-2009 02:09:24] PHP Warning: Divisi...

How well does the Recess! PHP Framework play with dojo.data?

Hello, I've been trying to find the perfect php framework for me that integrates with dojo smoothly. I am trying to avoid creating my own framework and I don't want to use the Zend Framework since I don't like it and I have a choice since it's my project. I really like the Recess! framework. It looks easy to get started with a easy to de...

php mysql gaming levelup script issues

Here is my problem. In my game I am trying to implement this leveling system where once you reached a certain amount of experience that you advance to a higher level. I am using php 5.0 and the Latest MYSQL. My problem is that i cannot get my scripts to execute properly. SO here are some dummy stats followed by my code Any information t...

Abstract a class away from PHP script?

Hey all, Just wondering if there is anyway to have PHP just run a certain class given the name of the file (controller.php)? I don't want to require, include or see any signs of it in the controller.php. I just want it to be there. EDIT: Ok. What I mean by run is in some file hidden away from me I say something like... $class = new Cl...

Why doesn't this prepare statement work in MYSQLI?

I created this code: $statement = $db->prepare("SELECT * FROM phptech_contact"); $statement->execute(); $result = $statement->result_metadata(); $object = $result->fetch_object(); print_r( $object ); When I run it, it doesn't work. Can anybody tell me why it doesn't work? I have 20 rows in this table so data should be returned. ...