php

How do I compare unix time stamps (numbers) inside a function in PHP?

Ok, I fear that this is just me having forgotten some small stupid thing about PHP, but I just can't seem to figure out what is going on here. Test code: <?php header('Content-Type: text/plain'); $closingDate = mktime(23, 59, 59, 3, 27, 2009); function f1() { return time() > $closingDate; } function f2() { return time() <...

How can I stream images from a webcam to my site using PHP?

I will be using PHP. I want to build a basic dating site so I think I need to learn how module by module or piece by piece until I have it completed. What I want to start with is the webcam part. How would I go about streaming a webcam to a website? How would I fetch a few screenshots of the webcam and post it on the site (storing i...

Website page becomes narrow when www prefix is not typed in browser

This is one of the strangest things I have seen. In Firefox 3 for PC, pages for a website we are developing become squeezed narrow, which makes the layout go completely nuts. If you type in http://www.wms-clients.com/vcb, the index page looks fine. If you type in http://wms-clients.com/vcb, everything is squished. Can anyone with FF3 ...

Sending large files reliably in PHP

Hi I have a php script on a server to send files to recipents: they get a unique link and then they can download large files. Sometimes there is a problem with the transfer and the file is corrupted or never finishes. I am wondering if there is a better way to send large files Code: $f = fopen(DOWNLOAD_DIR.$database[$_REQUEST['fid']][...

JSON Parse Error using FLEX and PHP

I am using JSON to parse data and connect to a PHP file. I am not sure what the problem is because I am a newbie to flex. This is the error I am receiving: JSONParseError: Unexpected < encountered at com.adobe.serialization.json::JSONTokenizer/parseError() at com.adobe.serialization.json::JSONTokenizer/getNextToken() at com...

How can I store the result of an SQL COUNT statement in a PHP variable.

I want to get the number of rows in my MySQL table and store that number in a php variable. This is the code I'm using: $size = @mysql_query("SELECT COUNT(*) FROM News"); $size ends up being "Resource ID #7." How do I put the number of rows directly into $size? ...

Apache not using mod_rewrite.c

So I just setup a linode server with debian, apache, etc. and now I'm trying to get an app that I'm developing running, but it requires mod_rewrite.c. So naturally, I went to the directory of the application (happens to be in PHP if that matters) and created a .htaccess with this inside of it: <IfModule mod_rewrite.c> RewriteEngine On R...

Suggestions on how to get bbpress / wordpress username/userid from cookie

I am trying to integrate my site to use the bbpress/wordpress user system. All I need is the ability to get the User Name and/or User ID of the person currently on my site. I don't really need any other functionality from bbpress or wordpress on the site. If I could get the user's ID and then the ability to get the user's name from th...

How to validate a MYSQL Date in PHP?

Users would select their date from 3 dropdowns (day, month, year). I will combine them on server-side to make a string like '2008-12-30'. How can I then validate to make sure this date was in the right format/numeric only, etc? ...

How can I programmatically obtain an image's REAL URL/Path?

To clarify the title question, I have code such as: <img src='gallery/main.php?g2_view=core.DownloadItem&g2_itemId=8161&g2_serialNumber=2&g2_GALLERYSID=5b24df90ee45f0e01795a3c01a1d634b'> with the file actually residing in the file system under my webroot. Is there any way in PHP to retrieve the images real path being served such as: ...

How to sort a date array in PHP

I have an array in this format: Array ( [0] => Array ( [28th February, 2009] => 'bla' ) [1] => Array ( [19th March, 2009] => 'bla' ) [2] => Array ( [5th April, 2009] => 'bla' ) [3] => Array ( [19th April, 2009] => '...

How can I send a ByteArray (from Flash) and some form data to php?

I have a sketch pad made in Flash AS3 like this one here: http://henryjones.us/articles/using-the-as3-jpeg-encoder I want to send the jpg to the server and some data from a html form field with php. Is there a way to force the Flash movie to deliver the image file when one presses the submit button? ...

In php how to do session instances?

I'm quite new on php and am trying to learn it. My question is rather simple but I've been a bit lost while googling for it. I just want to create an object to manage the database connection. I already did the object and now the problem I'm facing is: How do i keep it instanced to a session? (So that i don't need to open/close the con...

if statement switch

<?php if ($_GET['user_id']) $content = $_GET['user_id']; else $content = $_GET['content']; switch($content) { //The default page default: include_once('main.php'); break; //The news related stuff case 'news': include_once('news.php'); break; //Show the profile of a user case 'user_id': include_once('profile.php'); break; } ?> in...

PHP - '&' before the parameter name

Hey Just a quick and no doubt easy question. I'm pretty new to PHP and am looking through some existing code. I have tried to find the answer to my question on google, but to no avail. Can somebody please let me know what the '&' sign before the parameter $var does?? function setdefault(&$var, $default="") { if (! isset($var)) { ...

Help with a AJAX PHP and MYSQL Live Search!

Hi, i am trying to create a Ajax live search for my website. I currently can query the database for titles and display them under my search (See Fig 1.0) however i need to make them selectable so that when you do select them, it will set the input value to that title, very much like on wikipdia search Wikipedia Search. The wikipedia exam...

passing arbitrary html to a popup window

I am calling my makewindows fuction from a php file like so: echo "<a href='#' onclick=\"makewindows(" . $html . "); return false;\">Click for full description </a></p>"; This generates correct html, which results in a popupwindow containing the html from $html. For example(most of the html has been snipped): <a href="#" onclick="mak...

How would an ORM framework in PHP be structured?

I want to build a small ORM (Object Relational Mapping) framework in PHP. I want to do a mixture of an MVC approach, with the same controller/method/variable approach used by CodeIgniter. There are a few frameworks out there already which do this, but things like Form validation Pagination CRUD And AJAX are very difficult to do in t...

counting rows and passing information with mysqli

Hello, I have been trying to convert a php page to mysqli, and have encoutnered some problems. Given the code below, and the way which I have ordered things to work, I would like to know what the better way is using mysqli methods. Is there an mysqli alternative to mysql_num_rows or is a different method of calculating the number of ...

How to share APC cache between several PHP processes when running under FastCGI?

I'm currently running several copies of PHP/FastCGI, with APC enabled (under Apache+mod_fastcgi, if that matters). Can I share cache between the processes? How can I check if it's shared already? (I think the apc.mmap_file_mask ini setting might be involved, but I don't know how to use it.) (One of the reasons I think its not shared ...