php

new to php - hello world

I am new to PHP - just downloaded it and wrote hello world program: <html> <body> <?php $fileName = "test.jpg"; $txt="Hello World!"; echo $txt; ?> </body> </html> But it doesnt work. I named the file test.php and opened it with Firefox and nothing was displayed. ...

php objects define and set attributes in constructor

Is it possible to define attributes to a class in the constructor. For instance I pass a Associative Array to a class constructor and I want the attributes to that class to be declared and set based on what is in the Associative Array. TIA ...

PHP: TCP Connection Monitoring

Hi, I have an application that is used to connect ot a service once a week for a 1 hour session. This session has many requirements, one of which is that we only have one open tcp connection at a time. Out of the 30 or so sessions we've completed we've had 3 sessions where there were multiple tcp connections open during the 1 hour. I...

Unable to find tokens in string

I am trying to write a small php application and i am facing a problem. This is suppose to get text like : this is *noun but it is *name. And should take the words that start with a star and add them to the string tokens. However this is not working. // get list of fields (each should have words delimited by underscores $storyArr...

show hebrew words in a php response

hello.. i am sending a JSON response through a php script which has some hebrew words.but when i run this script on browser it is showing '?' instead of hebrew characters.. FYI.. database is in hebrew_general_ci collation any help would be appreciated.. thanks.. ...

Unable to get the text boxes and labels to be printed dynamically in php and HTML

I have this code and it should print labels with text boxes for people to fill in information. It takes a text like : $tokens = "*noun *noun *verb" and should print to the user a table that has : Noun: (text box to be filled) Noun: (text box to be filled) verb: (text box to be filled) etc. but it is not working echo "<form action=\"st...

working with XML in PHP

I have an url return an XML page result. When I use this command: print_r(file($url)); Its done, but when I use command: $doc = load($url); after that I : print_r($doc); it out. Its print_r out nothing. I'm quite new in work with XML in PHP someone give advise, please! Thank you for your attention! ...

continued : unable to post fields to the next page in php and HTML

So I have fields that are generated dynamically in a different page and then their results should posted to story.php page. fields is going to be : *noun1 *noun2 *noun3 and story is going to be : somebody is doing *noun1 etc. What I want to do is to replace *noun1 in the story with the *noun, I have posted from the previous page ( I have...

OpenID check_authentication not working.

I'm trying to get a check_authentication response working, but so far, all consumers reject it and say that my server denied check_authentication. This is the GET and POST data that my server file receives: $_GET: Array ( [mode] => profile [username] => hachque [domain] => roket-enterprises.com ) $_POST: Array ( [open...

PHP equivalent of ASP.NET Application/Cache objects

My Google-fu hasn't revealed what I'm looking for, so I'm putting this one out to the crowd. Coming from an ASP.NET development background, I'm used to having the Application and Cache collections available for me to stash rarely-modified but often-used resources (such as lookup rows from a database or the contents of static XML documen...

Regex to capture JPG images only

I have this regex in PHP: $regex = '/<img[^>]*'.'src=[\"|\'](.*)[\"|\']/Ui'; It captures all image tag sources in a string, but I want to only capture JPG files. I've tried to mess around with (.*) but I've only proven that I suck at regex... Right now I'm filtering the array but feels too much like a hack when I can just do it straig...

PHP Comparison Operators and Data Types

I'm currently working through O'Reilly's "Programming PHP" and have come across this table titled "Type of comparison performed by the comparison operators": First Operand | Second Operand | Comparison ----------------------------------------------------------------------- Number | Number ...

Kohana: Understanding and reproducing Salt & Hashed passwords using the Auth Module

I'm using the Auth Module in Kohana v 2.3.4. In terms of authenticating users, there's a two step process. The entry point is the function login. It's first task is to retrieve the password stored in the database and retrieve the password and determine the salt value. The salt is supposedly determined by an array of values, each corres...

Having trouble with uploading in php

I'm a very new programmer going through the O'Reilly book Learning PHP & MySQL 2nd ed. by Michele Davis & Jon Phillips. This is being stored on my home ubuntu server. I'm stuck on ex 11-28 where they want me to upload a picture and move it from tmp to an uploads folder if it meets certain conditions: file size, type, and whether or not ...

How to get the file type in PHP

I have a .doc file and I renamed named it to give it a .jpg extension. When I process the renamed file with my function it accepts the file as having a .jpg although the file is not really a JPEG. What's the best way to find the actual file type? Here is my current code: function getExtension($str) { $i = strrpos($str,"."); if (!$...

How to compare current website url to the website url in the database?

What is the best way to compare a current website url in your address bar with the url saved in the database? What I want to do is make it so if the url in the database is http://www.domain.com/ but the user types in http://domain.com/ it will 301 redirect to the domain saved in the database... The same will happen if the domain saved...

Intellisense for JQuery in Dreamweaver and Delphi4PHP

For all our AJAX programming we tend to use JQuery. I would like to know if there is a way to enable Intellisense functionality in Dreamweaver CS3 and Delphi4PHP to work with JQuery and its plugins? ...

Automatic Wordpress installation?

I've been wondering about making a blog hosting site like blogspot as a bit of a hobby. I figure Wordpress would be ideal to use but I'm not 100% on a lot of things related to this. Can I simply create mysql databases and wordpress installs with php functions and keep it secure from possible hacks? Or would the server as a whole need its...

Unit Testing CodeIgniter with Simpletest - very few tests

Hello all! On our development team, we decided to give Unit Testing a try. We use Simpletest. However, it's been a tough road. After a week, I only have created 1 unit test that tests a certain helper file. That's it. The rest (controllers, models, views, libraries) don't have unit tests yet. And I plan to not test a majority of them. Vi...

check if a site exists with PHP

is there a script in php to check if a site exists in the world wide web? submit a url script check if site is existing return true if it does ...