php

Method Chains PHP OOP

Hello, After seeing another question just started, I wanted to ask as to how something is actually achieved. When I use some frameworks they do this like $object->select('something') ->from('table') ->where( new Object_Evaluate('x') ) ->limit(1) ->order('x'); How do you actually do this kinds of chains...

Doctrine can't find a connection after Zend Framework redirect

I have some troubles with Doctrine integration into ZF. After simple redirect $this->redirector->setGotoSimple("asd"); Doctrine returns Doctrine_Connection_Exception: There is no open connection in /Users/insight/Sites/max/library/Doctrine/Manager.php on line 657 if i try to get this "asd" page directly or press f5 at the err...

Thinking logically about a database structure: Adding 'tags' to things users post - A seperate table or...?

Hi everyone! I'm still beginning to get my head around this whole relational-database-thingymawhatsit. Anyway, I'm a PHP programmer so I can do all that shabang. I just need to think what would be the best method for this scenario... I'm developing a site (with CodeIgniter if that's any help) - a site where users can post content (thi...

str_replace in php

hi, i have a long string that can hold all these values at the same time: hello<!>how are you? <!>I am fine<!> What is up? <!> Nothing! I need to find all these posibilities: ' <!> ' ' <!>' '<!> ' '<!>' And replace them with "\n" Can that be achieved with str_replace in php? ...

php image arrow line need to be smooth

im making a line in php and so far its showing fine, but what problem im getting now is the line is not being smooth, it shows as breaking edges. following is the code for making radius line: function draw_radius($img, $x1, $y1, $radius, $angle, $arrow_color, $arrow_length = 10, $arrow_width = 3) { $x2 = $x1 + $radius * cos(deg2rad(...

How can I display "please fill required field" in diferent languages using jquery.validate and ?lang=?

I'm using $lang = $_GET['lang']; and some arrays to change the language of the page. So my pages URL look like this when I select a language: ...index.php?lang=en (so my index page never changes neither my jquery files) (more details in my previous post) I'm using jQuery validate plugin to validate my form and a custom.js: $(document...

Multi-tiered MySQL query?

I have two tables(entries and tags) with a many-to-many linking table. Right now, I'm making a query to retrieve all the entries that meet my criteria, and a query for each entry to retrieve the tags. Would there be a way to say, have the tags returned through a new column as an array in the first query? ...

Retrieve value of a textarea with PHP

Hello again, Would anyone perhaps know how to get the value of a specific element in an HTML document with PHP? What I'm doing right now is using file_get_contents to pull up the HTML code from another website, and on that website there is a textarea: <textarea id="body" name="body" rows="12" cols="75" tabindex="1">Hello World!</textar...

It is possible to include Php variables or URL in Javascript in an If-statement?

I want to make some thing like this my-php-file.php $lang = 'es'; my-js-file.js if ($lang == es) { something-magical-happens; } or like this: if (URL == www.mydomain.com/index.php?lang=es) { something-magical-happens; } ...

user_timeline twitter API problem.

Hi. I'm using http://apiwiki.twitter.com/Twitter-REST-API-Method:-statuses-user_timeline to read the tweets of the user. When I used basic auth, it worked fine. When I switched to OAuth, the 'page' parameter stopped working. Like so: http://api.twitter.com/1/statuses/user_timeline/16.xml?count=25&amp;page=2 When I use OAuth to fetch t...

Creating HTML: PHP server-side vs. jQuery client-side

This is a design question. I have data that needs to go into an HTML table, which will later be manipulated by the user. Basically the user will be able to select items in the table rows. I have two options - in both cases I'm using AJAX to get the data: Create the HTML code using PHP on the server side, send it to the client as HTML....

Code outline for auto-update pages

I want to mess around with realtime information, and there is a pretty standard functionality that I want to duplicate: It occurs here on SO when you're on a single-question view, typing your answer, and an alert pops up top saying "there are 3 news answers, click to show" It also occurs on Twitter "There are 5 new tweets in this searc...

Mixing arrays and objects

I feel bad about mixing arrays with objects, but I'm not sure that I should. // Populate array foreach($participants as $participant){ $participants[$key]['contestant'] = new Contestant($participant); $participants[$key]['brand'] = new Brand($brand); $key++; } [...] // Print array foreach($participants as $participant){ pr...

decoding json value into a php variable

When I pass the results from getJSON to parseInfo() function just like the one below, is it possible to get results back into a php variable so that I could put the latter through another php function. $.getJSON('getinfo.php', { id:id }, parseInfo); function parseInfo(data) { <?php $some_var = json_decode(data); funct...

How to prevent HTTP Spoofing?

We have created a database driven website using PHP with set cookies and now need to prevent HTTP spoofing, any ideas on how to do this? we are beginners with this so any help would be greatful ...

PHP - Redirect to previous after logging in.

hi there. let's say I want to navigate to the contact page. but inorder to get there, the site requires me to login. after logging in, im supposed to be redirected to the contact page but im somewhere else. what should I do such that I should be redirected to the page I want after logging in? i have a strong feeling that this has some...

CakePHP Model: COUNT(*) in Containable

I have a CakePHP 1.3 app and really enjoy the Containable behavior for fetching data. Let's assume I have Posts in one-to-many relationship with Comments. I use Containable to query (for pagination) a list of all Posts and the belonging Comments. But I'm only interested in how many Comments each Post has. I did not found any way to achi...

Change queries dynamically - php, jquery

Hey I'm trying to get 2 main sql queries to be more dynamic. When the user clicks the marketing link, I want the 2 queries below to be updated with that link Id: 1. <?php generate_pagination('SELECT * FROM explore WHERE category="marketing"'); ?> so when the marketing link is clicked, I want the query to change the category in the qu...

How to insure column match for MySQL insert, when number and names of input fields will vary?

Hello! Working on a pre-existing program that parses an html form that has a dynamically created number of fields, and in the interest of forward-compatibility, may not even know number of mysql columns... I imagine that this requires creating two arrays, and comparing/re-ordering of some sort, but can't quite wrap my head around it......

Advice: building a non-database driven simple CMS in PHP

Hi guys, I'm working on a site which requires a very simple CMS - basically there's a block of text on the homepage that needs to be editable by the client. Their current hosting plan doesn't allow for a database, and including one will cost an extra $X a month which I think is unnecessary for such a basic system. The site is currently...