php

New Line problem when doing Ajax Post with JQuery

Hello, I'm trying to use Ajax with JQuery, what I want to do is just send multiline textbox value to php with Ajax. I'm using that code, it sends txtAnswer value to php, unfortunately, it removes new lines (\n) from data. How can I solve this problem... Thanks in advance.. $.post( 'post-answer.php', {answer: $("#txtAnswer").val(),...

Can't separate cells properly with simplehtmldom

I am trying to write a web scraper. I want to get all the cells in a row. The row before the one I want has THOROUGHBRED MEETINGS as its plain text value. I can successfully get this row. But I can't figure out how to get the next row's children which are the cells or <td> tags. if ($foundTag = FindTagByText("THOROUGHBRED MEETINGS",...

Use Unix timestamp in Doctrine Timestampable

How do I use Unix timestamps with the Doctrine Timestampable behavior? I found the following code snippet here, but I'd rather not manually add this everywhere: $this->actAs('Timestampable', array( 'created' => array('name' => 'created_at', 'type' => 'integer', 'format' => 'U', 'disabled' => false, 'options' => ar...

Alternative to passing variable info through URLs

I am writing a php/mysql app that uses a few different tables. Table 1 stores user information (name email etc), Table 2 stores that users widgets, and Table 3 stores those individual widgets' configuration. The way im doing this now, is Table 1 has an auto increment key that i use to idenfity that specific user. When they access table...

Linux command within Javascript or PHP

I have a linux command line that I need to execute witin either PHP or Javascript (PHP preferred.) The command is keygen AB3554C1D1971DB7 \pc_code 365 However, I would like to substitute the \pc_code with a string like $pccode where user enters the generated PC Code. This is for a legit project, but having a problem with creators of...

what is your method of directories with in a root.

ive created an mvc which has this level of organization as far as the folders and settings files go. +[admin] -[js] -[css] -[images] -[classes] --list of php classes -[includes] --config.php (includes db connection str --functions.php (php functions) --root--- [js] [css] [images] [classes] --list of php classes -[includes] --config....

how to extrapolate information from XML file in php

im using file_get_conents to retrieve an XML file. Lets say the xml file looks like this <tag1> <subtag1>Info</subtag2> </tag1> How would i go about retrieving Info from that xml file? ...

Headers already sent in php

Recently I worked in a project there I wrote the following code in top of the page: <?php session_start(); include_once('../module/connection.php'); $_SESSION['lang']=$_GET['ses']; if(($_SESSION['lang']=='') || ($_SESSION['lang']=='english')) { $l='japanese'; } else if($_SESSION['lang']=='japanese') { $l='english'; } When I run t...

Read MIME data using PHP

Hello, I have a third party program which basically allows users to send email and then it displays it in the system. But the problem is that it is generating an output like this: I want to just take this data and format it to something presentable. I would like to avoid REGEX. Are there any options or standard ways of displaying the co...

PHP regex using preg_match and capture group

I have a string that I want to search through: "Query Result: Val for ?f : http://www.rk.com/#steak Val for ?a : http://www.rk.com/#movietheaters" The two variables that I want to capture are the two words after the hashes (in this case steak and movietheaters). Note that there will always be an uri infront of the #. I know I can easi...

Example usage of AX in PHP OpenID

I'm using JanRain's PHP OpenID library. It comes with example script which is using SReg extension. But I want it to work with Google (and it works for auth actually), but Google uses AX (attribute exchange) instead of SReg for additional data. For some reason, JanRain's library is missing AX support in example script, and code comments ...

Getting the referrer URL in php ( including parameters )

Are there any HTTP Headers I could use to grab the entire referrer URL using a webserver/server-side scripting? Including query string, et cetera? ...

Weird 500 Internal Server Error (firebug, php, display_errors, ajax)

Guys, on one page I am doing multiple AJAX calls. All calls return responses successfully but the last one (not related to other ajax calls) returns 500 internal server error as response code (as firebug tells). However, in spite of error code, correct content is returned from that AJAX call. To my amazement, when I set display_errors ...

php class method is preventing xml from working correctly

Hello, I have a problem that I cannot understand I am trying to make my webservice work from a class. I try'd to echo the xml from some function in a controllerclass, but that diddn't work. So, I moved the xml around to a place where it did work. That means that I placed it before the loader function is called. That's where it still w...

how to insert row-by-row of content in a textfile into a mysql database?

i have a textfile that contains content like this bob james diva games library info and i was wondering how i can write a php script that would read the file line by line and insert the data into the database line by line as a new row for each line? thanks ...

APC Enabled but Apache Still Opening Files?

Hey guys, I'm working on a high-traffic webserver farm serving dynamic PHP code which includes around 100 files on most requests. APC opcode cache is enabled, include_once_override is enabled, and I have allocated 64MB ram to the cache, yet when I strace an apache process I still see it open()ing and stat()ing all of these includes for ...

Call Symfony's model layer from Outside the Symfony applications

I have a PHP script, it is located in the same computer as my Symfony application. Now the issue is how can I, in the PHP script, call the Symfony's model layer? The reason for me to ask this is because for the PHP script, it needs to access a database that Symfony application is accessing. So I think it might help if I can call the Mo...

What are some specific circumstances in which you used JSON over XML?

I still haven't really used JSON in a real world project - I pretty much always rely on XML. ...

What's the most efficient way to interact with a Singleton?

I've been working on my own little framework for a while for my own benefit, constantly going back over the code as I learn new stuff. As you might expect, I have a Registry object that's used by pretty much every other object. At present, the most basic object (AFObject) is set up a little like this absract class AFObject { var...

Best interface for reading XML in PHP?

SimpleXML seems ok, but one thing that's annoying is whenever assigning/storing a value you have to typecast it - this really is a tad annoying. DOM is ok but I really like the flexibility of XPath, sometimes DOM can be a tad too much writing-wise. I really like the selector implementation in jQuery, and the flexibility. I came across ...