php

Creating a user-defined code generation system in PHP

My newest project that I'm looking to build with PHP (likely CodeIgniter) would require some sort of system that would allow a user to drag and drop pre-defined functions/methods into mini-classes/objects and then run/test them in the browser. So it'd something similar to Scratch. I've designed a relational database that I think could w...

Why do I get this error when trying to set up a class variable

I'm new to PHP so maybe I am overlooking something here but the following: class someClass { var $id = $_GET['id']; function sayHello() { echo "Hello"; } } gives the following error: Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\files\classes.php on line 13 If instead of $_GET['id'] I s...

Checking Drupal authentication from external PHP

This may well be simple, but I'm new to Drupal. The organization I work for switched to Drupal a little while ago, but there's still some legacy code in various external PHP files that would be cumbersome to convert over to work within Drupal. However, it would be very nice to be able to restrict access to some of these pages based on a...

Why are $_POST variables getting escaped in PHP?

When my PHP script receives data from an AJAX POST request, the $_POST variables are escaped. The really strange thing is that this only happens on my production server (running PHP 5.2.12 on Linux) and not on my local server (running PHP 5.3.1 on Windows). Here is the AJAX code: var pageRequest = false; if(window.XMLHttpRequest) p...

php - ftp_get - Warning: ftp_get(): Opening BINARY mode data connection ...

I'm trying to write a script that will download files from an FTP server. They're all fairly large (nearly 2GB each). The script starts running, but then eventually terminates with the above error. Is it size related? Is there a way around this? Here's the code: <?php $ftp_server = "ftp.EXAMPLE.com"; $conn_id = ftp_connect ($ftp_s...

Zend: Fetching row from session db table after generating session id

Hi, I'm trying to update the session table used by Zend_Session_SaveHandler_DbTable directly after authenticating the user and writing the session to the DB. But I can neither update nor fetch the newly inserted row, even though the session id I use to check (Zend_Session::getId()) is valid and the row is indeed inserted into the table....

How to do an onclick ajax call to a php file, with jquery?

I have a link, which links to domain.com , when a person clicks, I want it to do an ajax call to counter.php and post 2 variables to it, so it can add 1 to the views for that link. I have a link: <a href="http://www.domain.com" onClick="addHit('12345', '1')" rel="nofollow" target="_blank">Link Title</a> How would I do this with jque...

Registration Form check PostgreSQL is username is already taken

Hey I'm really new to PHP and PostgreSQP or any database in that matter. So I'm at a loss how to do this. I need an if statement that says. If(the username user just typed in is already in database) { my code here } the variable the username that the user just typed in is $userNameSignup how would I do that with PHP for PostgreSQL...

thumbs.db messing up my upload routine

I'm getting the following error while uploading a zip archive. Warning: ZipArchive::extractTo(C:\xampplite\htdocs\testsite/wp-content/themes/mytheme//styles\mytheme/Thumbs.db) [ziparchive.extractto]: failed to open stream: Permission denied in C:\xampplite\htdocs\testsite\wp-content\themes\mythem\uploader.php on line 17 The thing I ca...

stripping a query string with php (preg_replace)

http://www.chuckecheese.com/rotator.php?cheese=4&amp;id=1 I want to take out the id, leaving the cheese to stand alone. I tried: $qs = preg_replace("[^&id=*]" ,'',$_SERVER[QUERY_STRING]); But that said I was using an improper modifier. I want to remove "$id=" and whatever number comes after it. Are regexp really as hard as they se...

session_id() in PHP

Hi, I am just trying the session_id function in PHP and I thought that it was unique for each machine that used the website? However, my flatmate and I have the same session_id for on two separate machines. I'm just using session_id() to create the session - am I doing it correctly? Thanks Tom ...

PHP Doctrine: filtering data which is already loaded?

I'm new to Doctrine and ActiveRecord. How should I filter a table after it has been loaded? (i suppose this is preferred over sending multiple queries?) Is this 'good' or 'bad'? class UserTable extends Doctrine_Table { function filterByGroup($group) { $ut = new UserTable(); foreach($this as $u) { if($u-...

accessing array values without square brackets in php

In php how can I access an array's values without using square brackets around the key? My particular problem is that I want to access the elements of an array returned by a function. Say function(args) returns an array. Why is $var = function(args)[0]; yelling at me about the square brackets? Can I do something like $var = funct...

useing my own db $info to replace parts of a url and open in a iframe

this dont work any options please? "Result below if printed" http://maps.google.com/maps/api/staticmap?center=WYOMING,WYOMING,MI&amp;zoom=14&amp;size=500x500&amp;maptype=roadmap&amp;markers=color:blue|label:S|42.902160,-85.696708&amp;sensor=false need to replace parts of url like shown above to enter "result" into an iframe src= ???...

SQL Query Not Functioning - No Error Message

ORIGINAL TEXT REMOVED OK, so I found the original problem thanks to a helpful answer. It lists "Invalid query: No database selected" as the error. require_once ('../dir_connect.php'); $dbc = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if (!$dbc) { die('Could not connect: ' . mysql_error()...

Yii: Multi-language website - best practices.

Hi, I find Yii great framework, and the example website created with yiic shell is a good point to start... however it doesn't cover the topic of multi-language websites, unfortunately. The docs covers the topic of translating short messages, but not keeping the multi-lingual content ... I'm about to start working on a website which nee...

PHP won't let page update automatically every day/6 hours

A friend build a ranking system on his site and I am trying to host in on mine via wordpress and godaddy. It updates for him but when I load it to my site, it works for 6 hours, but as soon as the reload is supposed to occur, it errors and I get a 500 timeout error. His page is at: http://www.jeremynoeljohnson.com/yakezieclub My page i...

search array and get array key

Hi all, I have an array, which I'd like to search for a value in and retreive the array key if it exists, but not sure how to even go about doing that. Here's my array: Array ( [hours] => Array ( [0] => 5 [1] => 5 [2] => 6 [3] => 6 [4] => 8 [5] => 10 ...

What about the event before order save in onepage checkout in Magento 1.4?

I write a function use observer in 1.3.2.4,the event name is "checkout_type_onepage_save_order". Now I want to move it to 1.4,but I see that the event "checkout_type_onepage_save_order" is disappeared,so I want to know how to write a observer before order saved in onepage checkout? ...

Maybe This is dead-simple stupid question, but how PHP translate our code ?

i got this code ` // // prints out "Hello World!" // hello_world(); //First call function hello_world() { echo "Hello World!<br/>\n"; } hello_world(); //second call ?>` Both of 'hello_world' call will print out the same result. It's easily to understand why the second call will be output 'Hello world', but ho...