php

Zend Framework : Using placeholders in Helpers

I created a custom helper, I was wondering if there was a way to access the view placehilders. class Zend_View_Helper_MyHelper { public function MyHelper { $this->view->appendScript('myscript.js'); } } I get: Call to a member function appendScript() on a non-object Thanks! ...

Can I limit PHP to just the file it's in (stop abuse?)

I'm making a small file editor and the only kicker is I don't want the people who have access to it do use dangerous functions like unlink chdir exec and I'm sure there's 100 more they shoudln't be able to use. I was thinking of just making an array of dangerous functions I don't want them to be able to use and when they save the file j...

php / mysql search query string

i'm trying to search terms that may or may not have a space... ex term: iPod Black 30. the results would be everything except, "ipod black used 30" and "used". so basically its finding all complete matching terms individual matching terms and skipping over any entry that may match but has a non-match word in it and of course the entry w...

How to use a Client Certificate with ftp_ssl_connect

I'm looking for the best method to work with an FTP server over an SSL connection. (Generally, pushing a file up as well as getting a list of files on the server). One requirement for this project is that I must use a client side X.509 certificate as part of the authentication process. Can I use a client certificate using the php functi...

Twitter API grabbing/caching/parsing multiple streams

Hi there, I need some thoughts in this :) I think i might be trying to do the impossible. I’ve got a website with a lot of company profiles (300+). I want to place a stream on every profile page, and allow the owner of that profile page to enter some keywords in the backend with the keywords they want the stream to display. 1 thing w...

Running MySQL *.sql files in PHP

I have two *.sql files that I use when creating a new web site database. The first file creates all the tables. The second file populates some default records. I would like to execute these files from PHP. I also use the Zend_Framework, if that will help accomplish this. Additional Info I don't have console access I'm trying to au...

I need to restore a database (mysql) every 30 minutes using a cron job.

I'm new to cron jobs and I need to restore a database (mysql) every 30 minutes. Is there a cron job command that can restore a database from a .sql file that's been gzipped? Or do I need to create a php script to do this and create a cron job to call this script every thirty minutes? Also, and this is a separate question but still rela...

Return minimum X (that can contain Y items) for arbitrary number of items

Feeling pretty brain-dead right now. I can, of course, brute-force this, but I feel like there has to be a simple function to return this number. Concerning native functions, I'm using PHP and/or Python. For example: there exists containers that hold X (5) breadsticks each, and I need to feed Y (25) people Z (3) breadsticks each. I ...

php+mysql: insert a php array into mysql

Hi I have an array with 30000 plus entries that need to go into a MySQL table. What is the best practice? From here? Lets say [0], [1] and [2] in the database would be 'title', 'type' and 'customer' Is it add key names matching the column names in the table and call som "magic" function? Or build the query manually... Array ( [0]...

Can php eval return a boolean value?

I cant seem to get eval to return a boolean value for '(4 > 5)' Is this possible? If not how might I get this to work (without writing a parser) I have tried this: $v = eval('return (10 > 5)'); var_dump($v); // Result = bool(false) UPDATE Thanks to @Pekka - I added a semicolon to the above code and it works. ...

Zend framework route chaining in ini file

I've got my routes configured as below: routes.rooms.type = "Zend_Controller_Router_Route_Static" routes.rooms.route = "/rooms" routes.rooms.defaults.module = "rooms" routes.rooms.defaults.controller = "index" routes.rooms.defaults.action = "index" routes.rooms.chains.room.type = "Zend_Controller_Router_Route_Regex" routes.rooms.chains...

[function.file-get-contents]: failed to open stream: HTTP request failed

Here is a snippet of my code: include("JSON.php"); $json = new Services_JSON(); $value=array('jsonrpc'=>'2.0', 'method'=>'methodname', 'params'=>array('param1',"param2"),'id'=>1); $output = $json->encode($value); print($output); $opts = array( 'http'=>array( 'method'=>"GET", 'header'=>"Accept: application/json\r\n"."Content-t...

How to figure out the Foreign Key Constraints of a MySQL table using Doctrine 1.1?

When two models are related to each other, Doctrine automatically generates foreign key constraints in the MySQL database beautifully. The default behaviour for onDelete and onUpdate RESTRICT, but can also be set to SET NULL or CASCADE. Now, I want to create a migration diff from an existing database compared to a YAML file. To do this,...

PHP MySQL - Delete Multiple Records Using Checkboxes

Hello, I am trying to figure out how I can delete multiple records using check boxes. I have a table on my page that gets the data from the database. The first column for each row has a check box that looks like the following: <input type="checkbox" name="checked[]" value='.$row['UserId'].' class="checkbox" /> My code looks like the f...

How can Interval be solved differently in php

I need to solve a problem like below. I'm not sure, can you suggest better method? switch(true){ case $price>100: tooHigh(); break; case (($price<=100) && ($price>70)): negotiate(); break; case (($price<=70) && ($price>20)): accept(); break; case ($price<=20): thankAndEscape...

A C++ Equivalent to PHP's fgets()?

Essentially what I'm looking for is a function with the following prototype: string getln(istream); All I need it to do is work like PHP's fgets(), that is, take an input stream as a parameter and return the next line from the stream. I feel like my current approach is somewhat bulky for creating a temporary variable each time it's call...

Html in my database!

Hello, I am faced with something I dont know where to start with. I currently have a news section on my website, the news is added into the database. However, it's very dull and has no formatting! How can I allow the admin thats adding news to make things bold or underlined and have colour etc. Will it be possible to save this in the d...

mysql and php - export specific row

Hello I have a test table with name mytable and with following data id name surname ================== 1 sotos val 2 john rik 3 peter ask How can id export for example the second row in mysql using php knowing the id? ...

A good "loading" function in combination with a picture upload utility (PHP + JS)

I have a classifieds website, and when posting a new ad, users may chose to upload pictures. Currently, the form on the page submits to itself whenever a file is chosen, and then PHP uploads the actual file, which is then lastly displayed to the user. I use javascript to set some hidden-inputs on the page, and then submit the form to i...

Could I please get some help correcting my little beginners project ?

Hi, This is my first time posting something like this. I'm a complete n00b at programming/php. I was trying to grasp all the tutorials out there and wanted to create a sort of framework to base projects off of for web db/applications. I came up with a few files for crud operations that I know must really be horrible code. I was wondering...