php

Best way to get the contents of TITLE TAG from page URL

Given a URL. What is the best way to get the contents of the title tag in the URL. Basically I want to check for the http_referrer and if it exists give a link back to the referring page. But I would like the link to say the title of the referring page. ...

Echoing <script> from PHP to jQuery AJAX causes problems with my interval

Basically, I'm grabbing contents from a PHP file. I check it every 5 seconds. If the content differs from the content on the page, it loads that new content: <script type="text/javascript"> $(document).ready(function() { $.ajaxSetup ({ cache: false }); var loadUrl = "<?php echo site_url("admin/get_uploads"...

PHP: How can I make a randomDate($startDate, $endDate) function?

i have made a function which works just fine with 32-bit dates (acceptable with strtotime), but that is not scalable. i need to randomly generate peoples dates of birth, so i must use DateTime (and only <=5.2.13, to make it even more difficult) functions to generate them. here is what i had: public static function randomDate($start_dat...

how can i post JSON object through cURL in php

How can I post JSON objects to a web service, through cURL in php? I have an array $data = array('username'=>'abc','password'=>'pass'); The webservice which I want to call accepts JSON object, if I convert the $data to JSON with json_encode, its not working for me. $data = json_encode($data); curl_setopt($ch, CURLOPT_POST ,1);...

Can't get Zend pdf show in browser

Hi, I've got a strange problem with zend pdf, I just can't get the pdf to show in my action i've got this code: $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $pdf = new Zend_Pdf('path/to/file.pdf'); $this->getResponse()->setHeader('Content-type', 'application/x-pdf', true); $this->getResponse(...

OAuth: Storing Access Token and Secret

We have a number of clients that use our API to power their websites. I have started a conversation at work about using OAuth to make authenticated API Calls. We will have both, two and three legged flows. For the 3-legged flow, we still have not come to a consensus on how to store the access token and secret. The common approach to...

concat tables with different content

Hi, I am currently building a small web application for publishing stories using PHP and MySQL. Each story may either be a article (with lots of fields and data), just a hyperlink/url, just an image, or a downloadable file with certain attributes (once again with lots of fields). My problem is related to finding the optimal database la...

Salting in PHP and MySQL

I have been developing a login library for a website using CodeIgniter. The authentication code is as follows: function signin($username, $password) { $CI =& get_instance(); $query_auth=$this->db->query('SELECT user_id, banned FROM user WHERE username=? AND password=SHA1(CONCAT(?,salt)) LIMIT 1', array($username, $password)); ...

Does Firefox synchronize requests for the same page?

I'm using Firefox 3.6.6. I have a PHP script called index.php with the following code: <?php sleep(20); die(time()); ?> I open two browser tabs, copy the URL into each of them, and then quickly hit enter in each tab. The first tab completes in just over 20 seconds. The second tab completes in just over 40 seconds. I do the same ex...

Error imploding $_POST[] array containing php variable

Hello, I am trying to implode an array in a $_POST[]. I am doing this inside of a loop which searches for values in ~31 arrays...$_POST['1'], $_POST['2'], $_POST['3'], etc. I am trying to do this with: while($i <= $_SESSION['daysInMonth']){ $month = $_SESSION['month']; $day = $i; $names = implode(',',$_POST['names_'.$i]); $region = $...

How can I get the description of a select multioptions tag in ZF?

How can I get the description of a select multioptions tag in ZF? If I do this, then I recieve the value, but a want the description $subjectTitle = $feedbackForm->getValue('subjecttitle'); ...

PHP How do I shift subset of array values to do something like asort?

Hello. First off I am new to this site and it is a big help, so thanks in advance for the input. I am trying to shift a subset of array values after comparing them, like asort. Here is what I have: $array[name] = "name"; $array[date] = "date"; $array[item1] = 7; $array[item2] = 16; $array[item3] = 3; $array[item4] = 16; $array[item...

PHP beginner: How to "Order by" that query?

Hello, I have a rather (I think) easy problem to solve but being a PHP newbie, I can't seem to get the answer... The query below, print a cloud of tags on my page. I'd like to add "ORDER BY TagID ASC" to this query so that the tags appeared according to their ID #, but I have no idea, where to put it (I didn't write that query, obvious...

Comparing XML documents for changes in PHP

Currently I'm using PHP to load multiple XML files from around the web (non-local) using simplexml_load_file(). This, as you can imagine, is quite a clunky process and is slowing load time significantly (7 seconds to load 7 files), and there could possibly be more files to load. These files don't change often, but changes should be displ...

Prevent memory overflow

At some point in my php script that makes use of curl, the following error shows up: "Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 77824 bytes) in"... It points out this part of the script: "$s = curl_exec($c);" What is the problem? And how to settle it down? ...

How do you style comments after they are pulled out of a database?

On my website you can post a comment, but I am unsure how to style them using CSS. I remember reading something about using ul and li tags but I can't figure it out. I want each individual comment to have a border, background color, etc. Here is the PHP: $query = "SELECT * FROM catharsis"; $result = mysql_query($query); $num = mysql_num...

PHP script redirection

Hi, I need help on redirect of php scripts. The problem is: I have a page for example www.domain.com/redirect.php?id=34 that redirects to another page, domain2.com/product.php?id=2. I need to create a script that allow me to know the URL of the redirection (domain2.com/product.php?id=2) just by accessing the redirector (www.domain.com/r...

What is the best method to populate form with jQuery?

Hello all, I have used jQuery Form plugin to submit the whole form data to server while Ajax. When the server code (php) returns, the retrieved data is in JSON format. What is the best method to populate the form with jQuery. Here is what I want to do: The user enters the data on the form The user submits the form data (I use ajax to...

securely pass api key from remote server to authentication page

This is my first time building an authenticated API and I'm running into a few roadblocks. How do I securely pass an API key from the remote client's page to my server (for the user to authenticate connecting his account to the client's page/app)? -dylan ...

How to increase number of iterations from within the loop in php?

Hi, I'm working on custom pagination system and encountered following problem. When one of the elements is filtered out of the set, the size of the final array is smaller than needed. Therefore I'm looking for a solution to increase the number of iterations from within the loop to always get array consisting of 50 elements. $limit = 50...