php

read all data recieved from a socket in PHP

I'm writing a simple telnet client library. I open sockets using fsockopen() and read and write to the socket using fgetc() and fwrite(). I use fgetc() instead of fread() to handle Telnet special commands and options like (IAC, ...). the problem is that most of times I'm reading from the socket, it takes too long to return. as I have pr...

delete session variable in php

Hi friends i create a webpage in that i use session variables , when i click logout i clear the session variables using ajax , it working fine in IE , But when i use firefox sometimes the session is not destroyed , the code i used to clear session is [when i click logout button] function floadhomepage(){ ajaxFunction();...

What mysql table structure to use in this case

Hello, I need to make the databse structure for a real estate website where users can create properties of many types and with many features related to the property. The main categories will be: 1. House (subtype apartment, house, loft) 2. Commercial (subtype: hotels, buildings, offices, factory) 3. Terrains (subtype: urban, agricola, ...

How do all these web platforms achieve a long-time login session that does not require the user to login over and over again?

I really don't get that: Some platforms have some kind of "persistent" login sessions. Like Stackoverflow and many other boards and platforms. I've logged in here a month ago. And even if I quit my browser totally and have another internet connection with different IP, I come back here with no login. I can't belief that's just done with...

SOAP replacements/workarounds/libraries in PHP

Being as stubborn as it gets, I'm building my own PHP-based CMS and framework (named RAmen/FSM just for the kicks) that has been deployed multiple times for my customers. Now, I'm going to develop a support ticket application for it that I will deploy on a 'central' server for convenience of maintenance. Now, I've looked into SOAP servi...

Is PHP suitable for very large projects? Can it be transaction-safe?

That question may appear strange. But every time I made PHP projects in the past, I encountered this sort of bad experience: Scripts cancel running after 10 seconds. This results in very bad database inconsistencies (bad example for an deleting loop: User is about to delete an photo album. Album object gets deleted from database, and t...

Is it possible to do mysql database transactions and rollbacks with php?

example: making a payment transfer from user A to user B. Account of user A: -10 USD Account of user B: +10 USD if there is an transaction, and something goes wrong, everything gets undone. So with transactions it will not happen that account of user A gets decreased by 10, while account of user B does not get increased by 10. I know t...

store in array or use multiple db queries

Within a php/mysql system we have a number of configuration values (approx 200) - these are mostly booleans or ints and store things such as the number of results per page and whether pages are 2 or 3 columns. This is all stored in a single mysql table and we use a single function to return these values as they are requested, on certain ...

Multiple domains point to one PHP file

2 of my urls, for example www.abc.com and www.def.com point to the same .php file. I have some text on that target page that needs to be dynamically changed depending on whether it came from www.abc.com or www.def.com. Can this be done? How? ...

Future proof file storage

I accept file uploads from users. Each file has a pointer in the db which has info on the file location in the filesystem. Currently, I'm storing the files in the filesystem non categorically, and each file is currently just named a unique value. All categorisation and naming etc is done in the app using the db. A factor that I'm concer...

How to properly work _around_ Javascript persistence?

There is basic persistence of Javascript vars/etc. You call a function/method, and the next time you call that same function/method, it is holding the data from the last time. You can delete the vars when you are done with them, but that removes the advantage of using the code again for that instance. So what is the proper way to write...

Exists any alternative more beautiful at this loop?

$i=0; while ($row=mysql_fetch_assoc()) { if ($i==0) echo "First" $i++; } Access directly to mysqli pointer? a php class like's Iterator? Thanks. ...

PHP: how to load file from different server as string?

I am trying to load an XML file from a different domain name as a string. All I want is an array of the text within the < title >< /title > tags of the xml file, so I am thinking since I am using php4 the easiest way would be to do a regex on it to get them. Can someone explain how to load the XML as a string? Thanks! ...

creating a unique key - most efficient way

I have two functions, makeKey() and keyExists(). makeKey() simply generates a 5 digit random alphanumeric key, keyExists() accepts this key as its only argument, and looks up in a table, returning true/false depending on whether it exists. I need to do something very simple but I cannot figure out the quickest way of doing it. I just...

Loading a PHP app/framework into memory only once possible with FastCGI?

I was under the impression that FastCGI allowed you to kinda load in your web app once, and then you just "provide" FastCGI with some function, like myHandleHTTPRequest($url), that would then be called whenever a request came. This way you'd get much better performance as your app is ready in memory all the time, right? But I'm starting...

PHP MySQL Joining Tables

I'm trying to create a directory and I have two tables, entry and location. Each entry will be able to have multiple locations so I'm assuming the best idea (correct if wrong) is to create a third table where I specify 'links'. Example: Marly:France Karla:Argentina Smith:USA Katie:France Smith:United Kingdom Katie:USA When I want to l...

Custom PHP FastCGI interface? (Faster?)

How do you build your own FastCGI interface in PHP? I'd like to do something similar to what they're doing in Perl, but in PHP. Is it even possible? Would it be faster? (That is, I'd like to be able to load a web app framework once into memory, and then just have FastCGI call a method I provide for every request. So not the more generi...

PHP: Get array of text from perticular XML node type?

I am not totally new to PHP or XML but I am 100% new to paring XML with PHP. I have an XML string that has several nodes but the only ones I am insterested in are the < keyword > nodes which there are an uncertain number of each containing a phrase like so: < keyword >blue diamond jewelry< /keyword > for example say the string looked lik...

Why and how would you use Exceptions in this sample PHP code?

Hi, I've been wondering why would I use Exceptions in my PHP. Let's take a look at a simple example: class Worker { public function goToWork() { return $isInThatMood ? // Okay, I'll do it. true : // In your dreams... false; } } $worker = new Worker; if (!$worker->goToWork()) { if (date('l',time()) == 'Sunday') echo "F...

Server process with PHP+MySQL

I am new to web programming, and I am developing a simple appointment app with PHP + MySQL. Is there a simple way to add a background process on a timer (to send out daily appointment reminders, for example)? This could be done easily in another language, but I want it to run on shared hosting with only PHP. ...