Need help reguarding the old PHP vs. new PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
a1strank
Forum Newbie
Posts: 2
Joined: Mon Aug 31, 2009 2:29 pm

Need help reguarding the old PHP vs. new PHP

Post by a1strank »

Here's the situation - my friend has a web-based program (or a site) made with PHP few years back and I believe it was made with older version of PHP - I was wondering is there a difference? I just recently build a new computer for him and I need to move that program to the new computer. I have WAMP server setup but when I copy everything over I get this huge line of code above the program - is this caused by php or mysql? Sorry I'm new to this so if I'm not making any sense please bear with me
EDIT: the purpose of this simple web based program is to save customer's data with phone number/dates prices etc

Code: Select all

$sqlerr"; } else { $submit = trim($submit); if ($submit != "") $action = ""; if ($action != "") { $area=$z;$phone1 = $a;$phone2=$b;$mon=$c;$day=$d;$year=$e;$ticket=$f;$quantity=$g;$price=$h; } /************** delete all found records ****************/ if ($action == "DeleteAll") { if ($_SESSION[custsqlwhere] != "") { mysql_query("DELETE FROM custrecord $_SESSION[custsqlwhere]",$db); if (mysql_error() != "") { $sqlerr = mysql_error(); $error = "There is a problem with your database, please contact wenchang for help
$sqlerr"; } else { $errmsg = "Records displayed have been deleted!"; } } else { $errmsg = "No records to delete!"; } } if ($submit == "" && $action == "") { // initialize variables $mon = date('m'); $day = date('d'); $year = date('Y'); } /*************** clear and reset the screen ***************/ if ($submit == "Clear") { $area == "000";$phone1 = "";$phone2 = "";$mon = "";$day = "";$year = "";$ticket = "";$quantity = "";$price = ""; $_SESSION[custsqlwhere] = ""; header("Location: $httploc/customer.php?action=clear"); exit; } /*************** delete by date range ***************/ if ($submit == "Delete") { $delmon = trim($delmon);$delday = trim($delday);$delyear = trim($delyear); $delmon2 = trim($delmon2);$delday2 = trim($delday2);$delyear2 = trim($delyear2); if ($delmon == "" || !is_numeric($delmon)) $errmsg2 = "Start Month is not valid."; if ($delday == "" || !is_numeric($delday)) $errmsg2 = "Start Day is not valid."; if ($delyear == "" || !is_numeric($delyear)) $errmsg2 = "Start Year is not valid."; if ($delmon2 == "" || !is_numeric($delmon2)) $errmsg2 = "End Month is not valid."; if ($delday2 == "" || !is_numeric($delday2)) $errmsg2 = "End Day is not valid."; if ($delyear2 == "" || !is_numeric($delyear2)) $errmsg2 = "End Year is not valid."; if ($errmsg2 == "") { $start = strtotime("$delyear-$delmon-$delday"); $start = date('Y-m-d',$start); $end = strtotime("$delyear2-$delmon2-$delday2"); $end = date('Y-m-d',$end); $sql = "DELETE FROM custrecord where date_in >= '$start' and date_in <= '$end'"; mysql_query($sql,$db); if (mysql_error() != "") { $sqlerr = mysql_error(); $error = "There is a problem with your database, please contact wenchang for help
$sqlerr"; } else { $errmsg2 = "Records between date range $start and $end has been deleted"; } } } /************ add new records ***********/ if ($submit == "Add New") { $sqlwhere = ""; $phone1 = trim($phone1); $phone2 = trim($phone2); if ($phone1 == "" || strlen($phone1) != 3) $errmsg = "Please enter a valid phone number."; if ($phone2 == "" || strlen($phone2) != 4) $errmsg = "Please enter a valid phone number."; if ($area == "000") $phone = "$phone1-$phone2"; else $phone = "$area-$phone1-$phone2"; $mon = trim($mon); $day = trim($day); $year = trim($year); if ($mon == "" || !is_numeric($mon)) $errmsg = "Month is not valid."; if ($day == "" || !is_numeric($day)) $errmsg = "Day is not valid."; if ($year == "" || !is_numeric($year)) $errmsg = "Year is not valid."; if ($errmsg == "") { $thedate = strtotime("$year-$mon-$day"); $thedate = date('Y-m-d',$thedate); } $ticket = trim($ticket); $quantity = trim($quantity); $price = trim($price); if ($ticket == "") $errmsg = "Ticket Number is not valid."; if ($quantity == "" || !is_numeric($quantity)) $errmsg = "Quantity is not valid."; if ($price == "" || !is_numeric($price)) $errmsg = "Please enter a valid price."; if ($errmsg == "") { // insert into database $sql = "INSERT INTO custrecord (phone,date_in,ticketnum,quantity,price) VALUES "; $sql .= "('$phone','$thedate','$ticket',$quantity,'$price')"; mysql_query($sql,$db); if (mysql_error() != "") { $sqlerr = mysql_error(); $error = "There is a problem with your database, please contact wenchang for help
$sqlerr"; } else { $lastid = mysql_insert_id(); $sqlwhere = "where ID=$lastid"; $result = mysql_query("select * from custrecord $sqlwhere",$db); $_SESSION[custsqlwhere] = $sqlwhere; $rows = mysql_num_rows($result); $errmsg = "Insert New Record Successful!"; // clear $area = "000";$phone1 = "";$phone2 = "";$mon = date('m');$day = date('d');$year = date('Y');$ticket = "";$quantity = "";$price = ""; $_SESSION[custsqlwhere] = ""; } } } /************ find records ************/ if ($submit == "Find" || $action == "Find") { $sqlwhere = ""; $phone1 = trim($phone1); $phone2 = trim($phone2); $mon = trim($mon); $day = trim($day); $year = trim($year); $ticket = trim($ticket); $quantity = trim($quantity); $price = trim($price); if ($area != "000") $phone = "$area%-"; else $phone = "%"; if ($phone1 != "") $phone .= "$phone1%-"; else $phone .= "%"; if ($phone2 != "") $phone .= "$phone2%"; else $phone .= "%"; if ($phone != "%%%") $sqlwhere = "phone like '$phone'"; if ($mon != "" && $day != "" && year != "") { $thedate = strtotime("$year-$mon-$day"); $thedate = date('Y-m-d',$thedate); if ($sqlwhere != "") $sqlwhere .= " AND "; $sqlwhere .= "date_in = '$thedate'"; } if ($ticket != "") { if ($sqlwhere != "") $sqlwhere .= " AND "; $sqlwhere .= "ticketnum = '$ticket'"; } if ($quantity != "") { if ($sqlwhere != "") $sqlwhere .= " AND "; $sqlwhere .= "quantity = $quantity"; } if ($price != "") { if ($sqlwhere != "") $sqlwhere .= " AND "; $sqlwhere .= "price = '$price'"; } if ($sqlwhere != "") $sqlwhere = "WHERE ".$sqlwhere; $sql = "SELECT * FROM custrecord $sqlwhere order by date_in"; $result = mysql_query($sql,$db); if (mysql_error() != "") { $sqlerr = mysql_error(); $error = "There is a problem with your database, please contact wenchang for help
$sqlerr"; } else { $rows = mysql_num_rows($result); if ($sqlwhere == "") $_SESSION[custsqlwhere] = "WHERE 0=0"; else $_SESSION[custsqlwhere] = $sqlwhere; if ($rows == 0) $findresult = "Unable to find any records."; } $mon = date('m'); $day = date('d'); $year = date('Y'); } if ($area == "000") $a0 = "SELECTED"; if ($area == "404") $a1 = "SELECTED"; if ($area == "770") $a2 = "SELECTED"; if ($area == "678") $a3 = "SELECTED"; } htmlheader(); ?>
User avatar
micknc
Forum Contributor
Posts: 115
Joined: Thu Jan 24, 2008 11:13 pm

Re: Need help reguarding the old PHP vs. new PHP

Post by micknc »

PHP 5 doesn't support short tags by default <? you have to use the full tag <?php. If I had to guess that is what I would say is going on because what you have posted is unparsed php.

Your options are to change that php.ini setting:
; Allow the <? tag. Otherwise, only <?php and <script> tags are recognized.
; NOTE: Using short tags should be avoided when developing applications or
; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.
short_open_tag = On

or use a find and replace program:
http://www.rjlsoftware.com/software/utility/search/
It will search all the files in a directory and do a find replace for you.

If I were you I would just do the find and replace and fix the problem instead of the symptom.
a1strank
Forum Newbie
Posts: 2
Joined: Mon Aug 31, 2009 2:29 pm

Re: Need help reguarding the old PHP vs. new PHP

Post by a1strank »

micknc wrote:PHP 5 doesn't support short tags by default <? you have to use the full tag <?php. If I had to guess that is what I would say is going on because what you have posted is unparsed php.

Your options are to change that php.ini setting:
; Allow the <? tag. Otherwise, only <?php and <script> tags are recognized.
; NOTE: Using short tags should be avoided when developing applications or
; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.
short_open_tag = On

or use a find and replace program:
http://www.rjlsoftware.com/software/utility/search/
It will search all the files in a directory and do a find replace for you.

If I were you I would just do the find and replace and fix the problem instead of the symptom.
Thanks for the help - You want me to DL that program and do a Search + replace every files on this web-based program from <? to <?php right? I tried that and now I'm getting a blank page when I try to load index.php


EDIT: I think you were about <? or <?php..because on the program in some fileds where you enter stuff it is suppose to be phone number's area code.but instead of the area code it is displaying <? Would I fix this program if I install PHP4??
User avatar
micknc
Forum Contributor
Posts: 115
Joined: Thu Jan 24, 2008 11:13 pm

Re: Need help reguarding the old PHP vs. new PHP

Post by micknc »

It would be easier to change the php.ini than to reinstall php4 so go that route if you want to try. Post the code for the index page and the code for the phone number page that you refereed to and I am sure someone we can get it worked out.
Post Reply