PHP5/Questions Answered by Expert Kevin Cackler

SubjectDate Asked
insert different code, based on URL/domain9/19/2011
  Q: We are wanting to split test domain names to see which converts best. For example: ...
  A: I'm not always super-fast to respond, I suppose. Sorry for the late reply! So your problem is ...
insert different code, based on URL/domain9/19/2011
  Q: We are wanting to split test domain names to see which converts best. For example: ...
  A: Luckily, this one is a simple one to answer. In your PHP code, wherever you want to insert the ...
php generated xml9/8/2011
  Q: Okay... here i am again. Got a big problem. (what's new?) lol What I am trying to do is get my ...
  A: The code I sent should work fine. The flash file only cares about the syntax of the document, and ...
php generated xml9/8/2011
  Q: Okay... here i am again. Got a big problem. (what's new?) lol What I am trying to do is get my ...
  A: I might be misreading the question, but I don't understand what the problem is. Here is how I would ...
Dynamic Web Site ( index.html or index.php ) ?8/21/2011
  Q: Kevin, how are you doing Sir? My question is, when designing a Dynamic Web Site does one use ...
  A: Martin - The file extension is actually completely meaningless. A file of ANY extension can be ...
Preventing Form Re-Submission PHP8/18/2011
  Q: I have a complicated form in that it has more than the usual contact form fields, including checkbox ...
  A: Sorry for the late reply. I had something all typed up, hit "Submit" and found that my session had ...
Array Construction7/25/2011
  Q: I have 3 comma separated lists as given below. ID = '901,947,925' ; Month= '1,2,3' ; Sales= ...
  A: The most simple way to accomplish this, so far as I can come up with, is to convert each string to ...
require_once(C:\PHP\www\PEAR.php)6/23/2011
  Q: I'm pretty new at all this still, and was wondering if anyone could point me in the right direction ...
  A: Pete - The error indicates that Mail.php is trying to include 'PEAR.php' and that it cannot find the ...
insert different URL's into page, based on6/19/2011
  Q: I know some CGI, but trying to learn PHP, but messing it up a lot =( ... I really need your ...
  A: Sorry Sam (again) for the late reply. Your follow-up went to my spam folder. Anyway - Now that ...
insert different URL's into page, based on "get"6/17/2011
  Q: I know some CGI, but trying to learn PHP, but messing it up a lot =( ... I really need your ...
  A: and thanks for the question. First of all, please allow me to apologize for the untimely response. ...
PHP Checkbox form5/10/2011
  Q: I need to make a list of checkboxes and have a submit button that will display the results of the ...
  A: John. This is a relatively simple problem to solve: In your form page: <form action="script.php" ...
Create links with mysql search results4/14/2011
  Q: I appreciate it very much! I'm teaching myself PHP/mySQL and other applicable tools for developing ...
  A: No need to thank me. I genuinely enjoy helping people out with these questions! :) And yours is a ...
count number backwards3/3/2011
  Q: First, I’d like to thank you for your time. You are doing this for free and I’m just amazed at the ...
  A: This has never led to a job opportunity for me (Not that I have much time for additional work ...
count number backwards3/3/2011
  Q: First, I’d like to thank you for your time. You are doing this for free and I’m just amazed at the ...
  A: Sam - As I wasn't sure what you wanted to do with the data, I simply left it stored in a variable in ...
count number backwards3/3/2011
  Q: First, I’d like to thank you for your time. You are doing this for free and I’m just amazed at the ...
  A: First of all, thanks for the kind words. It's nice to be appreciated. Second of all, what an ...
Add variable to specific spot of a specific array12/19/2010
  Q: I would like to add a value in the attributes array with string of 'class' with the value of ...
  A: It's late here, so I may not be completely on my game, but the following should do what you want (If ...
Add variable to specific spot of a specific array12/19/2010
  Q: I would like to add a value in the attributes array with string of 'class' with the value of ...
  A: Adam - If I'm understanding your question properly, this is very simple to accomplish. <?php ...
parameter passing PHP5 vs PHP49/28/2010
  Q: Very simple question that's driving me batty. My server just upgraded from php4 to php5.2.x and one ...
  A: Kevin - Your problem likely lies in the fact that your host PROBABLY had register_globals enabled on ...
Passing an array from one server to another by Form Post6/9/2010
  Q: I have a requirement of sending an array generated from Mysql database and PHP from my server to ...
  A: The most foolproof way would be to transform the array into an XML document and post that XML to the ...
PHP Script Emulator6/4/2010
  Q: I have some PHP and Wordpress scripts on my computer. I want to do some changes and use them. But ...
  A: Metin - I'm not sure why anyone placed this in the question pool, as it is a very simple question. ...
Sorting a list alphabetically12/8/2009
  Q: I have recently taken over as webmaster for a website - http://www.pendlebeerfestival.co.uk. The ...
  A: Is there any chance that you can provide the FTP information to me (BY EMAIL) so that I can take a ...
Sorting a list alphabetically12/8/2009
  Q: I have recently taken over as webmaster for a website - http://www.pendlebeerfestival.co.uk. The ...
  A: Gavin - Please amend the query line to read as follows $result = mysql_query("SELECT * FROM `beers` ...
Sorting a list alphabetically12/8/2009
  Q: I have recently taken over as webmaster for a website - http://www.pendlebeerfestival.co.uk. The ...
  A: Absolutely Gavin. You just need to add an order by for that column in the query. So you'll change ...
php security essentials12/7/2009
  Q: -I'm keen of building my site with PHP. Bu I'd like to know how worried should i be with general ...
  A: and thank you for the question. You should always be aware of security issues and always code ...
Are there any intermediate tutorials?11/13/2009
  Q: I'm decent with PHP and can get along with it, but I'm wondering if there are any tutorials that are ...
  A: Jerod - After you get the basics of the language down, I would say your next course of action should ...
EMAIL ADDRESS11/11/2009
  Q: I wonder if you can help. I have set up the email php so that when the users completes their details ...
  A: Dale, Assuming your mail() line currently looks something like this: $recipient=$_POST['email']; ...
Output apostrophes, quotation arks etc from Mysql database10/14/2009
  Q: I need to display mysql data with php 4 or 5 that has apostrophes etc. within the text. The data is ...
  A: If the value actually stored in the database field is Fred's Bakery (You've made sure that that ...
Output apostrophes, quotation arks etc from Mysql database10/14/2009
  Q: I need to display mysql data with php 4 or 5 that has apostrophes etc. within the text. The data is ...
  A: I apologize, but it's very difficult to understand what you're trying to do, still. However, if ...
Php5 pagination code with more link10/13/2009
  Q: This needs register_global_on to work but my host correctly refuses to turn it on...so I urgently ...
  A: I'm afraid I don't quite get what you're asking for, but I'll put a few answers here based on what ...
Easyphp Onto Compact Disc10/12/2009
  Q: Cackler, I'm a new to PHP programming and I recently signed up for a night class to ...
  A: EasyPHP is a package containing all of the necessary components to start developing in PHP right ...
Php5 pagination code with more link10/9/2009
  Q: This needs register_global_on to work but my host correctly refuses to turn it on...so I urgently ...
  A: Rather than checking for $id, you need to be checking for $_GET['id'] As an alternative (Though not ...
Display field value in dropdown10/1/2009
  Q: I am fairly new to programing in php. I have a form that is populated with the current values of ...
  A: Alan, you're actually very close to doing this right already. Here's what you need to do <select ...
php9/16/2009
  Q: kevin im completely new to PHP i wrote a simple 'hello world' program, but i cant find the way to ...
  A: You need to have PHP installed on the computer on which you want to execute the program. If this is ...
session life time9/10/2009
  Q: i have two Qs. : 1- about session life time.. i have a login page but session die after several ...
  A: 1. You can increase the session lifetime from within your script (If the php.ini file allows it) by ...
I have created a multilingual site with 3 languages and now i want to increase the languages.8/31/2009
  Q: I am Yogesh, a lead programmer. I have created a website with 3 languages (English, Polish, ...
  A: UTF-8 is acceptable to use in this case. If you were dealing with MOSTLY asian languages, I would ...
Static variable problem PHP8/28/2009
  Q: .. I would like to ask if anyone of you knows what was the problem with my script... here the ...
  A: What you're doing is simply not possible in the way that you're trying to do it. Class variables ...
PHP form question!8/24/2009
  Q: I'm trying to bang out a form script for my web site, but I have very little PHP experience so I'm ...
  A: Glad you're making progress. It's always nice getting something working that previously was not. ...
PHP form question!8/22/2009
  Q: I'm trying to bang out a form script for my web site, but I have very little PHP experience so I'm ...
  A: Ah, there is your problem. In order for PHP code to successfully execute, it must be accessed with ...
PHP form question!8/21/2009
  Q: I'm trying to bang out a form script for my web site, but I have very little PHP experience so I'm ...
  A: First of all, when debugging PHP scripts, it is often very helpful to add this at the top of your ...
Passing variables to URL just like using $_GET, but without forms8/19/2009
  Q: What I am trying to do is to pass a variable called "types" to my url "www.mypage.com", just like we ...
  A: If that is the case, then yes, you are close. You would do something more like: echo '<a ...
Passing variables to URL just like using $_GET, but without forms8/18/2009
  Q: What I am trying to do is to pass a variable called "types" to my url "www.mypage.com", just like we ...
  A: I guess I'm a bit confused at your question, as it seems like you've answered it yourself. <a ...
numerical values to graph7/31/2009
  Q: how to convert data (numerical value) from your database (mySQL) to a bar graph to be dsplayed in a ...
  A: I always take a simple approach to this. I figure out the average of the scores (In your case, the ...
multilingual web site7/26/2009
  Q: I am developing a site with mulitilingual feature.its working fine without any problem.first the ...
  A: However, if you want to put a quick fix in place, you could simply add columns whenever the user ...
PHP training7/11/2009
  Q: I am a long time computer consultant with programming background, and would like to learn PHP. Can ...
  A: my advice to you is to go out and download popular, well written scripts and just dive right in to ...
MySQL and Uploading4/14/2009
  Q: I find asking this question extremely difficult without being able to add annotation to the code ...
  A: Can you upload your modified code? The if(move_uploaded_file()) method should work perfectly in ...
MySQL and Uploading4/12/2009
  Q: I find asking this question extremely difficult without being able to add annotation to the code ...
  A: I apologize for the slow reply. A tornado rocked my hometown a few days ago and I've been pretty ...
Run a code4/11/2009
  Q: My q is so simple that i could not find it in previous questions. How do a run PHP script in a ...
  A: Basically, yes. You upload the script to your document/web root (IE /home/username/public_html, and ...
multiple php session management3/16/2009
  Q: Cackler, I'm using WAMP 2 server (PHP 5.2.8, Apache 2.2.11, Windows XP SP3) and I have a php portal ...
  A: The only thing that I can think of is to use session_id() to generate a unique session ID ...
drop-down list3/14/2009
  Q: how can I insert selected value from drop-down list to mysql ? for text filed am using ...
  A: First of all, you should NEVER put data into your database without first validating it and escaping ...
drop-down list3/14/2009
  Q: how can I insert selected value from drop-down list to mysql ? for text filed am using ...
  A: I don't know why your code is failing. I'm simply telling you that if you echo $_POST['city'];, you ...
Search Results Pagination3/12/2009
  Q: My question is simple but I'm not sure if the answer is just as simple. Maybe you can help. What I ...
  A: The basic things are as follows: 1 - How many results do you want to show per page? 2 - How many ...
about joomla script2/11/2009
  Q: I installed joomla script on a host and the host has given me the subdomain. I bought a domain ...
  A: First of all, you've set up your domain incorrectly. In most cases, you will point your domain name ...
Timeout Issue1/28/2009
  Q: I have a system created in AJAX (JavaScript, PHP) that uses the server to read data from a text file ...
  A: The max_*_time settings are what you would need to change to allow a long-running PHP script to keep ...
Downloading pdf files :D1/1/2009
  Q: im not a newbie with php , ive done many projects , but this problem is driving me mad , i want a ...
  A: There are several ways to do this Salman. One way is to stream your files through your PHP ...
How to save javascript variable in php variable??12/26/2008
  Q: This code for check time spend by user on page <body onload='window.setInterval("timeHere()", 100)' ...
  A: This isn't my area of expertise, but off of the top of my head, I can think of several ways to do ...
php12/26/2008
  Q: If I define a variable in one snippet of php code it carries on to another through an "include" ...
  A: I can honestly say that I've never seen this problem before. What happens if you change your code ...
program logic11/25/2008
  Q: I have having trouble with these files, one is called select.php and the update.php. The select.php ...
  A: If I understood your problem correctly, your problem lies in this line: $sql = "UPDATE goods SET ...
php4 to php5 migration11/1/2008
  Q: Sorry, forgot to show the .htaccess code in my first post: #Options -Indexes #Options ...
  A: Unfortunately, this really is an Apache specific question, as mod_rewrite doesn't have much to do ...
php4 to php5 migration10/30/2008
  Q: Sorry, forgot to show the .htaccess code in my first post: #Options -Indexes #Options ...
  A: Dave - This is actually not a PHP question (You're new to the PHP world, so I will forgive you) :) ...
.htaccess Rewrites for a php4 website now on a php5 server10/30/2008
  Q: The following .htaccess code redirected as shown to virtual files no problem on its original php4 ...
  A: Dave - This is actually not a PHP question (You're new to the PHP world, so I will forgive you) :) ...
php.ini configuration10/29/2008
  Q: i am getting problem with the file upload the file size is 5 mb i try my best to solve that problem ...
  A: If you are hosting your website on a Shared server (and most people are), then you will not have ...
getting url data and posting into db10/12/2008
  Q: i m stuck in a particular situation wile using php and mysql. i ll describe the scenario. i have ...
  A: I'm not sure I understand your question, but I will try to answer it anyway. To get the value of ...
merging two sites10/4/2008
  Q: How can i merge two sites together. Like merging twitter or flicker in the php site etc...? Plz ...
  A: This question is much more complex to answer than you realize. Both Twitter and Flickr have an API ...
Grabbing Text5/17/2008
  Q: Do you know how to grab a specific area of text from a website to be displayed in another site? ...
  A: XML parsing is INFINITELY easier than screen scraping, I'm happy to say. The following link is a ...
Grabbing Text5/16/2008
  Q: Do you know how to grab a specific area of text from a website to be displayed in another site? ...
  A: my experience with screen scraping is limited. I usually get content from remote sites by using ...
sessions5/13/2008
  Q: kindly forgive me if it is a silly question.I have developed an inventory package using php and the ...
  A: How are you storing your sessions? In flat files, a database, or a cookie? Many a time, I have ...
PHP ODBC Question5/6/2008
  Q: I have a web application where there is a connection being made to a database via odbc_connect(), ...
  A: Jacques - Without seeing your code, I cannot be 100% about my answer, but here it is anyway. You ...
The Code5/2/2008
  Q: Sorry about that. You ran out of available answers last night. Here is the full code that I put ...
  A: John - The problem, from what I can see, is the following section while($row = ...
random thingy5/1/2008
  Q: Now I am trying to make one of the table entries a random number. How would I do that. I am only ...
  A: Let me just show you how to select data from a database, and you can take it from there: ...
random thingy5/1/2008
  Q: Now I am trying to make one of the table entries a random number. How would I do that. I am only ...
  A: You're not being a pain. If I didn't enjoy helping, I wouldn't be doing this :) <?php $con = ...
random thingy5/1/2008
  Q: Now I am trying to make one of the table entries a random number. How would I do that. I am only ...
  A: <?php $con = mysql_connect(DB_HOST, DB_USER, DB_PASS); if (!$con) { die('Could not connect: ' . ...
Sending an sms via modem4/30/2008
  Q: Kindly let me know how to send an sms through a modem(GPRS preferably). Also kindly state the ...
  A: Unfortunately, I don't know a whole lot about sending SMS messages via PHP, so I'm not able to help ...
Making Paypal recurring Payment4/15/2008
  Q: i have done the request as .... <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" ...
  A: Make absolutely sure that your <?=$variables;?> are actually working. Just view the source of your ...
Based on a given number how can I determine the multiplier I need?4/8/2008
  Q: I'm making a game and I have it level based with the starting level being 0 of course. What I want ...
  A: I've racked my brain for a few minutes on this, and I can't find a mathematical way to define how ...
$_GET with variable names with '.'3/20/2008
  Q: I'm trying to get a list of checked files.. $filename='sample_1.txt'; print "<input type=checkbox ...
  A: It looks to me like it's an issue with register_globals (although I could be misreading that bug ...
Page ID3/18/2008
  Q: I'm new to PHP and can't find the answer to a simpleHow do i associate page ID's with filepaths? ...
  A: This can be done several ways. The easiest way is like so: <?php if(isset($_GET['id'])) { ...
database tables into flash?3/6/2008
  Q: Not sure how this is done (and even more so not sure if you can help me because I couldn't find ...
  A: The same concept can be applied to video uploading. ...
database tables into flash?3/6/2008
  Q: Not sure how this is done (and even more so not sure if you can help me because I couldn't find ...
  A: There is a way - That much I can guarantee you. Unfortunately, knowhow in Flash is exactly 0. I've ...
Learning PHP5 OOP with difficulty...3/2/2008
  Q: I'm in the process of learning OOP for PHP 5. It's really taking a long time, longer than most ...
  A: Rebecca - Thanks for the question. Unfortunately for those not already familiar with OOP, the PHP ...
php5+mail2/19/2008
  Q: firstly sorry for my English I'm Tunisian and didn't speak English so much. i have a problem with ...
  A: The most likely cause is that your PHP4 installation had register_globals enabled and the PHP5 ...
PHP Nested Loops.2/16/2008
  Q: i want output like in http://img264.imageshack.us/img264/9843/gallerynj2.png I have part of my ...
  A: Sorry about that typo. I should have been in bed 6 hours ago...Just can't sleep tonight (as you can ...
PHP Nested Loops.2/16/2008
  Q: i want output like in http://img264.imageshack.us/img264/9843/gallerynj2.png I have part of my ...
  A: OK, I'm going to do my best to answer this question in a way that will help you out... It looks ...
How to stop get method.2/16/2008
  Q: I want to validate the HTTP method and only allow POST unless GET is explicitly needed. My question ...
  A: Honestly - I see no reason for you to name an explicit list of variables that your script is ...
post with a link2/15/2008
  Q: I hate to bother you again but I really don't want to trust an important question to someone else ...
  A: Again here, you don't need to use echo to put that information into a query/command. ...WHERE ...
How to stop get method.2/15/2008
  Q: I want to validate the HTTP method and only allow POST unless GET is explicitly needed. My question ...
  A: Please correct me if I'm wrong here, but it sounds to me like you want to now allow a page to be ...
post with a link2/15/2008
  Q: I hate to bother you again but I really don't want to trust an important question to someone else ...
  A: I'm flattered ;) Now - My brain hurts from reading your description, but it sounds like you want to ...
Crystal Report and Php2/4/2008
  Q: Kevin Can we call a crystal report from php? if so how can we call, can pls give an ...
  A: Unfortunately, I don't have any experience with Cyrstal Reports. However, a quick google search ...
creating links for database results12/22/2007
  Q: i have a some data in a mysql database, and i'm building a php based site. i would like to retreive ...
  A: You're asking a lot of questions at once, here. You need to take it step by step. 1: If the URL is ...
os variable store in PHP variable12/18/2007
  Q: I want to store %username% (in cleint system) value in php variable. i have tryed using system(). ...
  A: I doubt that you will be able to pull this off using only PHP. Your best bet would be to create a ...
php Login system12/14/2007
  Q: I am a newbie to php so it is a very basic query. I have designed a login system, in which when the ...
  A: That's very weird - I've never seen this problem before. For testing purposes, you should open your ...
page redirection12/13/2007
  Q: I'm building a site wich uses php5 and mySQL. i've following up on how to redirect pages, and found ...
  A: Because header("Location") is...well, a header, it must be sent to the browser before any output is ...
.htaccess--Talkback comment script11/23/2007
  Q: I have installled a comment script called Talkback.(link below) ...
  A: In this case, it really would be best for you to contact Godaddy directly. As I'm not a godaddy ...
PHP Debug mode11/5/2007
  Q: i've looked a lot for documentation on php debug mode, but am enable to find it. I have noticed an ...
  A: Well you're on the right track. The documentation, as you stated, is very poor on this subject. ...
Connecting database from two servers11/1/2007
  Q: Is it possible to connect database fromm two different servers? If yes, can you help me in it. Its ...
  A: I'm not sure what you're asking here. I will respond to what I think you might be saying, however. ...
Php Reporting10/30/2007
  Q: Kevin I have developed a project using Php and MySql. I have create some forms for ...
  A: I purchased a license for http://www.websitedatabases.com/database_reports.html a few months ago, ...
Php and MySql with Crystal Reporting10/29/2007
  Q: Kevin I have develop a database software using Php and MySql. I want to use Crystal ...
  A: If your PHP installation and Crystal Reports installation are on the same Windows based system, you ...

All Questions in This Category

PHP5

All Answers


Answers by Expert:


Ask Experts

Volunteer


Kevin Cackler

Top Expert on this page

Expertise

Any and everything related to PHP4 and PHP5. I specialize in functional, readable, scalable object oriented code, and can answer your troublesome class and object questions.

Experience

5 years developing in PHP using flat files and databases (MySQL, Oracle) Lead PHP developer for a very large Texas based web hosting company The coder behind some of the largest pet communities online.

Education/Credentials
BS - IT/CS

©2012 About.com, a part of The New York Times Company. All rights reserved.