php

PHP Doctrine toArray problem

I have a problem with the toArray() method in Doctrine. Its doesn't get my relations: First query : $q = Doctrine::getTable('posts')->find(1); debug($q->toArray(true)); Print the postid=1 with out the relations $q = Doctrine::getTable('posts')->find(1); $q->Tags->toArray(); debug($q->toArray(true)); ...prints the results with tag ...

Zend framework: what is the right place to validate user input?

I want to add a user in users table via link like '/index/adduser/id/7' . Question Should I validate user input inside 'adduserAction' function inside controller or somewhere inside model file? I've put files containing database related functions inside 'models' directory. Suppose a user is added to a table via 'id'. This id is sent vi...

wordpress .htaccess with permalinks

I have a permalink working but as soon as I create a post it tells me that soory post not found permalink setting is to "/%pagename%/" and here is .htaccess: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /ryan/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d R...

PHP - parse a value outcome to HTML

Hello, I want to use something like this in a PHP file: $about = array ('dutch' => 'over', 'spanish' => 'sobre', 'english' => 'about'); if ($USER['lang'] == 'dutch'){ // $about - becomes 'over' } elseif ($USER['lang'] == 'spanish') { // $about - becomes 'sobre' } else { // $about - becomes 'about' } And transfer the outcome to...

Blog post comment without page refresh (ajax)

Hello everybody, I'm trying to make comments on my page just like the ones in wordpress. When you press post comments your page updates without reload. How can I do that? I understand I have to use jquery post, and I've had several attempts but for some reason my web page keeps reloading. I have a form like this : <form name="postForm...

Using str_replace and include together (php)

I have a footer in a web page, the footer is called footer.php. I'd like the footer to have a different image depending on other variables. I want to do something like this: if (x=1) {include (str_replace('logo1.jpg','logo2.jpg','footer.php'));} else {include 'footer.php';} But this doesn't work, it just does a regular include. Is ...

Why is error coming up for TinyMce blog editor?

I have installed the TinyMce blog editor to my site. When the compose blog page loads a I get a pop up that has the yield sign and says "Developer Key Validation Failed" Anyone know what this is? <script type="text/javascript" src="javascripts/jquery/jquery-1.3.2.min.js"></script> <script type="text/javascript" src="http://www.cysticlif...

Problems with strings in PHP (not adding two strings together properly)

if we say: $termstringDomain1 = "something"; $url = "somethingelse"; $url = 'http://' . $termstringDomain1 . '/' . $url; the result if gives me is: http:///somethingelse instead of http://something/somethingelse so basically it is ignoring $termstringDomain1 Any idea why? ...

Wordpress include("../../../wp-blog-header"); failing

I am currently working on a plugin for Wordpress involving lots of .php files. I see that for my AddShift.php file, we are successfully importing the blog header using the following line of code: include("../../../wp-blog-header.php"); However, when I try to do the same thing in my ajax_cal_split.php file, I get the following error: ...

How can I fetch EXPLAIN PLAN FOR an Oracle SQL query from PHP?

I'm using Oracle 10g Express on Windows XP, and on a Macbook OS X 10.5.8 running PHP 5.3.1 with PDO and Oracle Instant Client 10.2.0.4.0_4, I run the following script: <?php $pdo = new PDO("oci:dbname=winders:1521/xe", "system", "XXXXXX"); ... $sql = "WITH NumberedBugs AS ( SELECT b.*, ROW_NUMBER() OVER (ORDER BY bug_id) AS RN ...

recieving only the structure of the table using SQL and PHP and put into an Array

Is it possible to recieve only the structure of the table even if its emtpy and put the field names in an array. if so wich sql command makes that possible. thanks Matthy ...

When to pass-by-reference in PHP

Im wondering if its good practice to pass-by-reference when you are only reading a variable, or if it should always be passed as a value. Example with pass-by-reference: $a = 'fish and chips'; $b = do_my_hash($a); echo $b; function &do_my_hash(&$value){ return md5($value); } Example with pass-by-value: $a = 'fish and chips'; $b ...

Not encoding already encoded items with htmlentities

I have a string that looks something like this: Bürstner &nbsp;&nbsp; When I use htmlentities() on it, I set the double encode param to false, but it still ends up re-encoding the &nbsp; into &amp;nbsp; I'm using this to encode: $out = htmlentities($string,ENT_NOQUOTES, 0); Am I somehow misunderstanding how this works? The desire...

When using PHP to pass important data...

When passing data to another PHP script using Get or Post, should I encrypt it with a MD5 with salt? or is there a better way to do it? ...

How to use preg_replace outside <script></script> in php

I've got a string : $source = '& <script type="text/javascript">&</script> & <script type="text/javascript">&</script> &'; The desired result is : &amp; <script type="text/javascript">&</script> &amp; <script type="text/javascript">&</script> &amp; I try with : echo preg_replace("#&(?!amp;)(?!<\/script>)(?![^<]script.*?>)#i", ...

How can I get phpmail to send to the right user and also limit the ammount of emails for certain users? Part 2.

Thanks to Anthony's advice I've tried to simplify my logic and syntax of the goal I am trying to achieve which is when a blog is written, the AUTHOR gets notified by php mail that someone other than himself comments. When the AUTHOR comments everyone else who commented except him gets a different email. When another user comments, the AU...

Posting an array with curl_setopt

Hi, The attached code is returning "Notice: Array to string conversion in...". Simply my array is being handled to the remote server as a string containing "Array" word. the rest of the variables are fine. How can I pass my array ($anarray) without this problem? Thanks. <?php $data = array( 'anarray' => $anarray, 'var1' => ...

PHP - How to split a paragraph into sentences.

I've been trying to use $string="The Dr. is here!!! I am glad I'm in the U.S.A. for the Dr. quality is great!!!!!!"; preg_match_all('~.*?[?.!]~s',$string,$sentences); print_r($sentences); but it doesn't work on Dr. , U.S.A., etc.. Does anyone have any better suggestions? ...

How to rewrite if exists a php file with the same name?

Hello, I was searching in Google this question very much time but I don't find any answer. I want to rewrite http_//mydomain.com/f to http_//mydomain.com/ This is my .htaccess code: Rewriterule ^f$ / [R=301,L] rewrite works, but if exists a file called f.php, then doesn't work I tried to do this: RewriteCond %{REQUEST_FILENAME} !-...

Is it possible to use PDT to debug through a tunnel with XDebug?

I'm trying to debug using PDT and Xdebug over a tunnel and haven't been able to get PDT to connect properly. I do not have PHP installed on the machine I am developing on and would like to connect to the XDebug instance that is running on my development machine that is not able to talk directly with my machine. ...