php

Is there a way to specify the source UDP port using PHP?

I need to send a message via UDP to a remote equipment. I know that if I use the same UDP port that it used while sending information to the server to write back to it the messages goes through. I am currently using: $fp = fsockopen( $destination, $port, $errno, $errstr); if (!$fp) { echo "ERROR: $errno - $e...

How to upload a file using Java HttpClient library working with PHP - strange problem

I want to write Java application that will upload a file to the Apache server with PHP. The Java code uses Jakarta HttpClient library version 4.0 beta2: import java.io.File; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.HttpVersion; import org.apache.http.client.HttpClient; import org.apa...

PHP associative Array

I have an associative array in PHP $asd['a'] = 10; $asd['b'] = 1; $asd['c'] = 6; $asd['d'] = 3; i want to sort this on basis of its value and to get the key value for the first 4 values. how can i do that in php ??? ...

Read from STDIN on a Git pre-commit Hook (with PHP)

Hi, I'm looking for a way to have git-commit wait for standard input. I'm coding this in PHP, as my bash skills are non-existant, so I thougth doing a regular <?php $input = trim(fgets(STDIN)); fscanf(STDIN, "%d\n", $line); ?> would do the trick, and wait until I write stuff in to continue, but it just goes ahead and continues executi...

Calling a field from database in MySQL

return(array($clientName,$salesPer,$prospectVal,$projID)); The projectID is dynamically added in database for each entry, now how can i return the ID. As i have not set any variable in PHP to map the database field. Can anyone guide me on this. ...

include path and cron

I'm running a cronjob that calls a php script. I get "failed to open stream" when the file is invoked by cron. When I cd to the directory and run the file from that location, all is well. Basically, the include_once() file that I want to include is two directories up from where the php script resides. Can someone please tell me how I ca...

PHP: remove array element by element pointer (alias)

Is it possible to remove an array element by a pointer? Multidimensional array: $list = array( 1=>array( 2=>array('entry 1'), 3=>array('entry 2') ), 4=>'entry 3', 5=>array( 6=>array('entry 4') ) ); Reference array: $refs = array( 1=>&$list[1], 2=>&$list[1][2], 3=>&$li...

could not retrieve field name from database...

$result = mysql_query("INSERT INTO project (clientname, salesperson, prospect) VALUES ('$clientName','$salesPer','$prospectVal')"); while ($row = mysql_fetch_assoc($result)) { $projectID = $row['projectid']; return $projectID; } I am not getting the projectID from the database. The fi...

Not returning the entire values from the table....

$result = mysql_query("SELECT * FROM project ORDER BY projectid"); while($row = mysql_fetch_array($result)) { return(array($row['projectid'], $row['clientname'], $row['salesperson'], $row['prospect'])); } I get only the first set of values from the fields. I need all the values. ...

Magento: externally get relative URL's to categories.

I'm building a website, and installed Magento in the /shop/ subdirectory. I'd like to integrate the top categories into the menu of my non-Magento site, so you can navigate directly into the category. For this I need the category names and url's. Magento's categories are: Templates Color Theme General Other products I first needed...

How Drupal works?

I have yet to see a comprehensive overview about how Drupal really works. Most of the tutorials are about lame things, like adding a module or configuring a site. Where is a flowchart about how the page gets generated? Most of the documentation is clumsy too. What's the best resource for learning how Drupal really works? ...

selecting divs retrieved through AJAX in jquery

Hi, I'm creating a basic forum where every message contains the authors name, some text and the date it was created. I'd like the forum to update constantly through AJAX, and show new posts that were created on the fly. I currently have a PHP file getlatest.php?lastid=... that retrieves all posts from the ID given to the most current. It...

Propel custom Setter with SQL-specific stuff

Hello stackoverflow gurus I am using Propel 1.2 in a Symfony 1.0 project, with PostgreSQL db. I can use Criteria::CUSTOM in SELECT statements in order to use Postgres functions, like this (fulltext search): `$c = new Criteria(); $c->add(MyTablePeer::FULLTEXT_COLUMN, MyTablePeer::FULLTEXT_COLUMN." @@ to_tsquery('english', 'text to sear...

PHP shorthand rewrite

Probably really easy for a pro, but could someone re-write this from it's PHP shorthand form to non-shorthand? ($facebook) ? $fb_active_session = $facebook->fbc_is_session_active() : $fb_active_session = false; Thanks! ...

What will the following print?

What will the following code print? print ‘’four’’ * 200; ...

Keep code in separate file

topic.php $id = isset($_GET['id']) ? intval($_GET['id']) : 0; $query = mysql_query("SELECT * FROM topics WHERE id = $id"); $row = mysql_fetch_assoc($query); $title = htmlspecialchars($row['title']); $text = bbcode($row['text']); view/topic.php <h1><?=$title?></h1> <p><?=$text?></p> <h1>Replies</h1> $q = mysql_query("SELECT * FRO...

MySQL PHP mysql_real_escape_string() - is this value not a string?

I am trying to update a record with the info from a multiple select box, I had it working fine when I was using INSERT INTO to add a new row, but now that I am trying to add it to this code that is using mysql_real_escape_string() it is returning the error message at the bottom of this post. I presume it has something wrong with the val...

Array return type problem in PHP

function showFields($selClient) { $result = mysql_query("SELECT * FROM project WHERE projectid = $selClient"); $values = array(); while($row = mysql_fetch_array($result)) { $values[] = array($row['clientname'],$row['prospect'],$row['salesperson']); } return $values; } When i return the value...

how much more efficient will it be to develop in PHP if using Zend Framework than not ?

I haven't determined to learn about zend framework, so your advice is important for me to make a final decision! ...

Big problem in IE 7, Wordpress pages wont scroll

Well Wordpress is pretty key to my website, Ive had many a problem with IE but now its a major problem, as you can see (link removed due to possible malware; see history for link). Firefox, Chrome, Safari are great, including the latest version of IE I think, but IE 7 does not show the scroll bar or page down. Any ideas what could be m...