php

Need help understanding Owning & Inverse side in Doctrine

how can i using common sense, or that objects model the real world understand how doctrine determines which side is owning or inverse and how relationships are uni/bi-directional? say from the doctrine sandbox. 1 user has 1 address. i guess since user owns the house/address, user is the owning side? The owning side of a relationship...

Very illogical php value comparisons.

I stumbled upon a very strange bit of PHP code. Could someone explain why this is happening? **BONUS POINTS** if you can tell my why this is useful. <?php if(0=='a'){ print ord(0)." should NEVER equal ".ord('a')."<br>"; } if(false==0){ print "false==0<br>"; } if('a'==false){ print "a==false<br>"; } ?> And the resu...

PHP Timeouts and FTP function

In implementing the backup script I described in this serverfault question, I ran into some timeout issues that have prompted optimizations to the code (namely, backing up one file per execution of the script and doing everything I can to minimize the number of file-hashes I am calculating over the very large data files). So far, that ...

Need help understanding Doctrine one to many

Referencing doctrine reference - one to many unidirectional class User { // ... /** * @ManyToMany(targetEntity="Phonenumber") * @JoinTable(name="users_phonenumbers", * joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")}, * inverseJoinColumns={@JoinColumn(name="phonenumber_id", referencedColumn...

How can I make a function that repeats itself until it finds ALL the information?

I want to create a PHP function that goes through a website's homepage, finds all the links in the homepage, goes through the links that it finds and keeps going until all the links on said website are final. I really need to build something like this so I can spider my network of sites and supply a "one stop" for searching. Here's what...

Security: Form Submission + javascript/jQuery

Question: What is best practice for form submissions while keeping in mind security? This may be a n00b question but I'm concerned that people might be able to alter some data as its being submitted. Take my example: I have a form that has a hidden input that stores a user's unique Facebook ID. I take that Facebook ID and create a use...

How to add index to 18 GB innodb mysql table without affecting production performance?

How can I add index to an 18 GB innodb mysql table without affecting the production performance? The table is frequently accessed, I tried altering the table just now and it turns up to have locked more than 200 queries out, and that's bad for performance. Are there any other ways to do it? ...

Making sense out of many to many relationships in Doctrine

referencing doctrine reference - association mapping - many to many bidirectional /** @Entity */ class User { // ... /** * @ManyToMany(targetEntity="Group", inversedBy="users") * @JoinTable(name="users_groups", * joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")}, * inverseJoinColumns={@JoinC...

What are \r and \n meaning in PHP?

what are these called \r \n and is there a tutorial that explains them? ...

cant get mongodb to work with php

hello, i have fedora 13, and i have installed httpd,php,mysql using yum. then downloaded mongodb. added the extension=mongo.so to my php.ini restarted httpd wrote the following code : <?php $connect = new mongo(); $db = $connect->data; $collection = $db->foobar; $info = array("name" => "wael", "age" => 24); $collection = insert($info...

Wordpress - how to integrate PHP code into a page?

Hi, I have a simple HTML form that posts to a PHP page, which will then return the user some content. I want to take this PHP code and get my wordpress theme to wrap around it, so that appears like a normal page on my site. Can't find any resources on this - where do I begin? Thanks. ...

php array generation challange

Please help. I need randomly generate an 2 dimensional nXn array . lets take for now n=10; array should have such structure. one example $igra[]=array(0,1,2,3,4,5,6,7,8,9); $igra[]=array(6,9,1,5,0,2,7,3,4,8); $igra[]=array(2,5.................... $igra[]=array(1,7..................... $igra[]=array(5,4................... $igra[]=arr...

How to display the latest 4 news?

I have a news script. This script works like the following: I enter the news details from a form The news is inserted into the database The news is displayed to the visitor I need to display the latest 4 news only, not all news entries. How can I do this? ...

php explode new lines content from a txt file

I have txt file with email addresses under under the other like : [email protected] [email protected] So far I managed to open it with $result = file_get_contents("tmp/emails.txt"); but I don't know to to get the email addresses in an array. Basically I could use explode but how do I delimit the new line ? thanks in advance for any answer ...

PHP Foreach loop take an additional step forward from within the loop

Basically I have a foreach loop in PHP and I want to: foreach( $x as $y => $z ) // Do some stuff // Get the next values of y,z in the loop // Do some more stuff ...

PHP get index of last inserted item in array

It's as easy as the title sounds; I need to get the index/key of the last inserted item. Why is this difficult? See the following two code samples: $a=array(); echo 'res='.($a[]='aaa').' - '.(count($a)-1).'<br>'; echo 'res='.($a[]='bbb').' - '.(count($a)-1).'<br>'; echo 'res='.($a[]='aaa').' - '.(count($a)-1).'<br>'; die('<pre>'.print_r...

What is better hashed or encrypted passwords?

What is best for storing passwords? Should I be Encrypting or hashing password for you users table ? What do you prefer, and why? Could you please provide an example of secure password storage. ...

Tetris'ing an array

Consider the following array: /www/htdocs/1/sites/lib/abcdedd /www/htdocs/1/sites/conf/xyz /www/htdocs/1/sites/conf/abc/def /www/htdocs/1/sites/htdocs/xyz /www/htdocs/1/sites/lib2/abcdedd what is the shortest and most elegant way of detecting the common base path - in this case /www/htdocs/1/sites/ and removing it from all elements...

Image resize PHP

Hi, Im trying to create a simple image resize feature, can you tell me where i'm going wrong: //resize image $imageSrc = imagecreatefromjpeg('http://www.katsmurals.com/cms/'.$target_path); $width = imagesx($imageSrc); $height = imagesy($imageSrc); echo $width; echo $height; //new dimensions $i = $width; $j = $height...

Block in drupal - prints nothing, what's wrong with my script?

I have a block that I want to show edit and delete buttons for users with access, and other buttons for the rest of the users. This is the script I'm using for the users with update permission: <?php if(arg(0) == 'node' && is_numeric(arg(1))){ //load $node object $node = node_load(arg(1)); //check for node update access ...