php5

mysql get last auto increment value

Hi I have a field in mySql table called jobnumber which auto increments with each new entry. What I want to do is when a user views my form, get the value of the next 'jobnumber' . But I want to do this before any entry is made to the table. IE so when a user looks at a form it will display something like 'this is job number 6954' I ha...

What is the purpose of return'ing $this when setting vars in the model

I am a self thought hobby programmer and therefore don't have the fundamentals always down the way you professionals do. So please excuse me if this is basic. What is the purpose or benefit of return'ing $this when setting vars in the model. I have seen this done in other places too but cant figure this out. Sample code: public functi...

PHP $_SERVER['REMOTE_HOST'] returns ::1

Hi I am trying to get the IP address of the website visitor in PHP. I'm expecting $_SERVER['REMOTE_HOST'] to return something like 127.0.0.1, but it's returning ::1. Kind regards Peter ...

File Upload drops with no reason

Hallo I want to make an file upload. The script should take the image, resize it and upload it. But it seems that there is any unknown to me error in the upload. Here the code define ("MAX_SIZE","2000"); // maximum size for uploaded images define ("WIDTH","107"); // width of thumbnail define ("HEIGHT","107"); // alternative he...

cPanel's SMTP or google hosted SMTP ?

Hi, I'm wondering what mail servers I should use for sending mail through my website, avoiding them sent as spam. Hostgator SMTP google hosted SMTP I found that to avoid a mail sent as spam it should have the same host in "From:" and "Received". How to overcome this? Thanks ...

php echo doesnt print newlines

Hey ! I started doing a new project in PHP / MySql . The Aim of this project is to manage articles for a magazine that i am the editor of. So the content of the articles, i decided i would store with the "TEXT" column type of MySql Now when i retrieve this column and print it with echo, the newlines are not there. Its all on the sam...

Improve performance of website

I have designed a new web site. I have hosted it online. I want it to be of the best performance and load pages faster. This website is designed in php 5.0+ using codeigniter. This is using mysql as DB. I have images on it. I am using Nitobi grid for displaying set of records on page. The rest is everything normal page controls. As i ...

PHP New Line Help

I'm just starting PHP programming as you can tell. I want the results of each statement to be on their own line but can't get it to work yet. I tried referring to the code on this page and am obvsiously doing something wrong. Thank you very much. <? $mySentence="This is a sentence 123456789."; $myNumber1 = 9.5; $myNumber2 = .5; $sum ...

Real life examples of actionStack helper in Zend Framework

Do you know any real life examples of actionStack() action helper in Zend Framework? It seems quite a big overhead to have multiple dispatch loops. Then when it is really needed? ...

Sensible Doctrine Expression and Zend_Auth setCredentialTreatment()

How to create reasonable expression to store password in database using Doctrine and Zend_Auth::setCredentialTreatment()? I don't want to use md5() and the code must be portable, and with salt. I would call this not easy one to guess: setCredentialTreatment("SHA1(CONCAT(username, SHA1(CONCAT(username, ?)))"); but it is not portable t...

PHP reads 1.10 value as 1.1 (0 at end of variable not honored)

Hello, This is hard for me to word, but easier for me to demonstrate: I have a select option: <option <?php if($frequency[$key]=='1.10'){echo "selected";}?> value='1.10'>1 every 10 days</option> Really, $frequency[$key]=1.1; , but the above still shows up selected. I've never seen this before, and didnt know it could happen. Any id...

PHP OOP question about reference

Can one please explain with example what does $obj->$a()->$b mean? I've used PHP OOP quite a long time and have seen in some places this structure and not just this $obj->$a(); In what cases should I use it? Thanks in advance! ...

What's slowing for loops/assignment vs. C?

I have a collection of PHP scripts that are extremely CPU intensive, juggling millions of calculations across hundreds of simultaneous users. I'm trying to find a way to speed up the internals of PHP variable assignment, and looping sequences vs C. Although PHP is obviously loosely typed, is there any way/extension to specifically assi...

Extracting the common words between two paragraphs?

How can I extract the common words between two or more paragraphs in php5? I guess it might work to summarize each text to create a list of highly ranked words and then compare them. Any suggestions or help would highly appreciated. ...

Working with PHP Octals and String conversions

I'm working with a database that has a bunch of serial numbers that are prefixed with leading 0's. So a serial number can look like 00032432 or 56332432. Problem is with PHP I don't understand how the conversion system with octals works. A specific example is that I'm trying to convert and compare all of these integer based numbers...

Enable PDO for PHP5 on CentOS5 where PHP is configured as '--disable-pdo'

Hi I have been given access to a CentOS5 machine by my client for their new site which uses Zend Framework. phpinfo() states in Configure Command that PDO is disabled ('--disable-pdo'). How can enable it? Do I need to recompile PHP5 to enable it? I have tried adding 'extension=pdo.so' in php.ini and restarting Apache, but this didn't...

Check for Duplicates in a Database Before Entering Data

Before Entering data into a database, I just want to check that the database doesn't have the same username in the database already. I have the username in SQL set as a key, so it can't be duplicated on that end, but I am looking at finding a more user-friendly error message then "KEY already exists". Is there are simple way to check i...

parse search string

I have search strings, similar to the one bellow: energy food "olympics 2010" Terrorism OR "government" OR cups NOT transport and I need to parse it with PHP5 to detect if the content belongs to any of the following clusters: AllWords array AnyWords array NotWords array These are the rules i have set: If it has OR before or afte...

A PHP object server for business logic

I wonder if such a thing is possible or even exist : In the MVC pattern, I would like to have the Model part to be persistant in memory, instead of reloading my instances at each execution. So I want only the Controller and View part to be executed. Is there any solution of server that would provide PHP objects (just like a Mysql serve...

include or required

What should I use in the following statement? Include or required. if(a ==b){ require 'requiredfile.php'; } else { require 'requiredfile_2.php' } If in a function, I know that one, either include or require, only includes the file when called, the other one will include the file regardless. Am I correct? ...