php

Parse error: syntax error, unexpected T_PUBLIC in ..... ?

Hi, I am new to php and trying out this tutorial at : http://css-tricks.com/php-for-beginners-building-your-first-simple-cms/ Unfortunately I am getting the following error and can't seem to track down the reason: Parse error: syntax error, unexpected T_PUBLIC in ../simpleCMS.php on line 56 My code for simpleCMS.php is as is in the...

How to enable/create elements on the fly

Hi all I am using a combination of PHP, jQuery and Spry to serve a series of listboxes in which a user will select first the type of vehicle, then the make, then the model and finally the specific model. All my listboxes (SELECT) are working fine, and they update properly using the Spry elements. Each listbox is populated from a diffe...

Recursion in prepared statements

I've been using PDO and preparing all my statements primarily for security reasons. However, I have a part of my code that does execute the same statement many times with different parameters, and I thought this would be where the prepared statements really shine. But they actually break the code... The basic logic of the code is this. ...

Catch not working and how to unset the exception handler

catch is not working because there is installed an exception handler using set_exception_handler() I need "catch" to work, so I guess I need to unset the exception handler somehow. Things such as set_exception_handler(NULL) isn't working. Any ideas how to unset the exception handler? function my_exception_handler($exception) { er...

Should I include locally or remotely?

Just something I wonder about when including files: Say I want to include a file, or link to it. Should I just for example: include("../localfile.php"); or should I instead use include("http://sameserver.com/but/adirect/linkto/localfile.php"); Is one better than the other? Or more secure? Or is it just personal preference? Clearl...

Complex SQL query... 3 tables and need the most popular in the last 24 hours using timestamps!

Hey guys, I have 3 tables with a column in each which relates to one ID per row. I am looking for an sql statement query which will check all 3 tables for any rows in the last 24 hours (86400 seconds) i have stored timestamps in each tables under column time. After I get this query I will be able to do the next step which is to then c...

passing string to a AJAX/JSON function

I’m having trouble getting a AJAX/JSON function to work correctly. I had this function grabbing value from a drop down box but now I want to use an anchor tag to set it's value. I thought it would be easy to just use the onClick event to pass string to the function I was using for the drop down box but it doesn’t do anything. I’m stumpe...

copying html page with mysql data in php

I am trying to copy a file into a folder called profile. I got that working, but I need the page to be .html. I also need data from MySQL to put in the .html page. How do I go about that? ...

problem with creating a new module using vtlib 2.1 for vtiger CRM 5.0.4

I have created a new module in vtigerCRM using the vtlib 2.1 api doc as provided in the following link. http://wiki.vtiger.com/index.php/Vtiger_CRM_5_Developer_Guide/VTLIB Though the module appears to have been created successfully I am getting the following error when I try to add a new record. ( ! ) WebServiceException: Permission to ...

czech char 'ě' on php page script

Hi guys, I'm not able to correctly show this char on my web pages. I'm using UTF-8 charset for this page, have I to use ISO-8859-2? I'm getting this a string with this char from a db and on it, it's saved as ě. My Browser show only html tag. It's the only char (at this moment) that I can't show on my webpage. I've take a look to t...

PHP Priority Queue Implementation

I just finished coding a complex job assignment application where a lot of the work was done using priority queues. When I deployed, however, I discovered the web server ran PHP 5.2. Has there been an implementation for PHP<5.3 that can server as a drop-in replacement for SPLPriorityQueue? ...

How to deal with JSON output that might be an array, or might be a value

Hi - I'm getting JSON-encoded output from another organization's API. In many cases, the output can be either an array of objects (if there are many) or an object (if there's just one). Right now I'm writing tortured code like this: if ( is_array($json['candidateList']['candidate'][0]) ) { foreach ($json['candidateList']['candidat...

Dynamic jQuery popup with PHP

So I have dynamically generated content from a MySQL database and I pull it with php. To show what I mean look this example. Goto http://minecraftadmins.net/browse/ See Skin Preview? I want to make it so when you click it, it opens a jQuery popup with content generated from an external source (AJAX). I know how to make a popup. But it d...

How to Pass a JS Variable to a PHP Variable

Hello: I am working on a web application that currently provides a list of documents in a MySql database. Each document in the list has an onclick event that is suppose to open the specific document, however I am unable to do this. My list gets popluated using Ajax. Here is the code excerpt (JS): function stateChanged() { if (xmlh...

What is the best way record monthly user uploads to our web application?

Our web application allows users to upload photos, it uses a PHP script on a LAMP server running on Amazon EC2 to handle image uploads, Amazon S3 to store the files and a MySQL database for recording data about the image (user id, filename, tags etc). I intend to have an image_uploads table in the database with a colum for each month an...

JSON onFailure issue

I’m having trouble getting a AJAX/JSON function to work correctly. I had this function grabbing value from a drop down box but now I want to use an anchor tag to set it's value. I thought it would be easy to just use the onClick event to pass string to the function I was using for the drop down box but I get the alert in JSON onFailure ...

Strip the first page of a Word Doc using PHP

Hi all, I'm trying to strip the first page of a MS Word Document (may be .doc or .docx) using PHP. I've had a search round and couldn't find much, other than libraries that help create .doc files, but none that have the ability to read in a .doc and manipulate it. Thanks, Andrew ...

PHP and ajax no update taking place

Hi There, I have an an ajax request that looks like this, $('input.fakecheck').click(function(){ alert("deleteing...."); $.ajax({ url:"/search", type:"POST", data: $(this).attr('name')+"="+$(this).attr('value')+"&remove=Remove", success:function() { alert(data); } }) }) This calls a php function which l...

Checking if a php process is already running

Hi. I'm trying to check if a process is already running by using a temporal file demo.lock: demo.php: <?php $active=file_exists('demo.lock'); if ($active) { echo 'process already running'; } else { file_put_contents ('demo.lock', 'demo'); sleep(10); //do some job unlink ('demo.lo...

Are PHP5 objects passed by reference?

I cant seem to get any consistent info on this. Different sources appear to say different things and trhe venerable php.net iteslf (appears) not to explicitly state this - although I must admit, I only had a quick look. In cases where I am passing around 'heavy' objects, I need to pass by reference, but I dont want to keep typing: func...