Need help reguarding the old PHP vs. new PHP
Posted: Mon Aug 31, 2009 2:37 pm
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
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(); ?>