Forum Moderators: coopster

Message Too Old, No Replies

Parse error: syntax error, unexpected T STRING, expecting T OLD FUNCTI

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION

         

zander64

11:31 pm on Jun 11, 2011 (gmt 0)

10+ Year Member



I am getting this error after uploading to go daddy, help.


Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/content/w/s/e/wsegventure/html/Allianzsurgical/As_admin/include/Connection.php on line 4

<?php
class AI extends Exception
{
public $link;
public $db_name;
public function AI()
{
session_start();
if(!isset($chars))
{
$sym = array('¶', '¥xQ', '|');
foreach(range('a','z') as $key=>$val)
$chars[$val] = str_repeat($sym[0],($key + 1)).$sym[1];
$chars[' '] = $sym[2];
unset($sym);
}

}

//Database Connection
public function connect()
{

/* Online beta version */
/*$db_host = "localhost";
$db_username = "root";
$db_password = "";
$this->db_name = "medicalequipment";*/

/* Local */

$db_host = "wsegventure.db.6789426.hostedresource.com";
$db_username = "wsegventure";
$db_password = "Justdoit64";
$this->db_name = "wsegventure";

$this->link=mysql_connect($db_host,$db_username,$db_password)or die(mysql_error());
mysql_select_db($this->db_name,$this->link)or die(mysql_error());

}

//Database Query
function dbQuery($sql)
{
$query = mysql_query($sql) or die(mysql_error());
return $query;
}

//Last Inserted ID
function lastID($tbl)
{
$sql="SELECT auto_increment AS incre_id FROM information_schema.tables WHERE table_name='$tbl' AND TABLE_SCHEMA='$this->db_name'";
$query=mysql_query($sql) or die(mysql_error());
$res=mysql_fetch_object($query);
return $res->incre_id;
}

//Database Fetch_Array
function fetchArray($farr)
{
$query = mysql_fetch_array($farr) or die(mysql_error());
return $query;
}


//Database Fetch_Object
function fetchObject($fObj)
{
$query = mysql_fetch_object($fObj) or die(mysql_error());
return $query;
}

//Database Fetch_Object
function Num_rows($frows)
{
$query = mysql_num_rows($frows) or die(mysql_error());
return $query;
}


//Database Close
function dbClose()
{
mysql_close($this->link);
}

//Showing Alert Message
public function alertMessage($message)
{
?>
<script type="text/javascript" language="javascript">
alert('<?php echo $message;?>');
</script>
<?php
}

//Success Dialog
public function showDialog($title,$message,$name,$time)
{
?>
<script type="text/javascript" language="javascript">
showDialog('<?php echo $title;?>','<?php echo $message;?>','<?php echo $name;?>','<?php echo $time;?>');
</script>
<?php
//$this->redirectLocation('index.php');
}

//Redirecting location
public function redirectLocation($location)
{
?>
<script type="text/javascript" language="javascript">
window.location="<?php echo $location;?>";
</script>
<?php
}
//Encrypt a string
public function encryptString($str)
{
for($i=0; $i<3;$i++)
{
$str=strrev(base64_encode($str));
//apply base64 first and then reverse the string
}
return $str;
}

//Decrypt a string
public function decryptString($str)
{
for($i=0; $i<3;$i++)
{
$str=base64_decode(strrev($str));
//apply base64 first and then reverse the string}
}
return $str;
}

//Administrator User Security
public function adminSecurityCheck()
{
if(!isset($_SESSION['sess_admin']))
header("Location: index.php");
}

public function adminIndexCheck()
{
if(isset($_SESSION['sess_admin']))
{$this->redirectLocation('welcome.php');}
}

//User Security
public function userSecurityCheck()
{
if(!isset($_SESSION['session_timeout_start']))
{
$_SESSION['session_timeout_start']=time();
}
else
{
$session_timeout = 10800; // 30 minutes (in sec)
$session_duration = time() - $_SESSION['session_timeout_start'];
if ($session_duration > $session_timeout)
{
session_destroy();
header("Location: index.php"); // Redirect to Login Page
}
else
{
$_SESSION['session_timeout_start']=time();
}
}

if(!isset($_SESSION['sess_user']))
header("Location: index.php");
}

//Checking image formate
public function checkImage($type,$size)
{
$mb=2;
$maxSize=$mb*1048576;
if(($type=='image/gif') ||
($type=='image/jpeg') ||
($type=='image/bmp') ||
($type=='image/jpg') ||
($type=='image/tiff') ||
($type=='image/raw') ||
($type=='image/png') ||
($type=='image/pjpeg') and
($size < $maxSize))
return 1;
else
return 0;
}
public function imageResize($max_width,$max_height,$image)
{
list($width, $height, $type, $attr) = getimagesize($image);

$width_percentage=$max_width/$width;
$height_percentage=$max_height/$height;

if($width_percentage <= $height_percentage){
$new_width=$width_percentage*$width;
$new_height=$width_percentage*$height;
}else{
$new_width=$height_percentage*$width;
$new_height=$height_percentage*$height;
}

$new_image=array($new_width,$new_height);
return $new_image;
}
public function createThumb($imgDir,$image,$max_width,$max_height)
{
$ctMsg=array();
/*print_r($image);*/
//Image Validation
$iFlag=$this->checkImage($image['type'],$image['size']);

if($iFlag==1)
{
//Proportional Shrinking of image
$pSize=$this->imageResize($max_width,$max_height,$image['tmp_name']);
$pSize1[0] =$width;// $this->imageResize(450,450,$image['tmp_name']);
$pSize1[1] =$height;

$imagePath = "$imgDir/".$image['name'];

$thumbPath = "{$imgDir}/thumb/".$image['name'];

if(is_uploaded_file($image['tmp_name']))
{move_uploaded_file($image['tmp_name'],$imagePath);
$ctMsg["uploadImg"]="Success";}

//Thumb creation
$source_image_path=$imagePath;
$thumbnail_image_path=$thumbPath;
list( $source_image_width, $source_image_height, $source_image_type ) = getimagesize($source_image_path);

define( 'THUMBNAIL_IMAGE_MAX_WIDTH', $pSize[0]);
define( 'THUMBNAIL_IMAGE_MAX_HEIGHT', $pSize[1]);
switch ($source_image_type )
{
case IMAGETYPE_GIF:
$source_gd_image = imagecreatefromgif( $source_image_path );
break;

case IMAGETYPE_JPEG:
$source_gd_image = imagecreatefromjpeg( $source_image_path );
break;

case IMAGETYPE_PNG:
$source_gd_image = imagecreatefrompng( $source_image_path );
break;
}

if($source_gd_image === false)
{
return false;
}

$thumbnail_image_width = THUMBNAIL_IMAGE_MAX_WIDTH;
$thumbnail_image_height = THUMBNAIL_IMAGE_MAX_HEIGHT;
$thumbnail_gd_image = imagecreatetruecolor($thumbnail_image_width, $thumbnail_image_height );
$imgFlag=imagecopyresampled( $thumbnail_gd_image, $source_gd_image, 0, 0, 0, 0, $thumbnail_image_width, $thumbnail_image_height, $source_image_width, $source_image_height );
imagejpeg( $thumbnail_gd_image, $thumbnail_image_path, 90 );

//Changing the size of the original image
$thumbnail_gd_image1 = imagecreatetruecolor($pSize1[0], $pSize1[1] );
$imgFlag1=imagecopyresampled( $thumbnail_gd_image1, $source_gd_image, 0, 0, 0, 0, $pSize1[0], $pSize1[1], $source_image_width, $source_image_height );
imagejpeg($thumbnail_gd_image1, $imagePath, 90 );

imagedestroy( $source_gd_image );
imagedestroy( $thumbnail_gd_image );
//imagedestroy( $thumbnail_gd_image1 );
if($imgFlag)
$ctMsg["msg"]="Success";
else
$ctMsg["msg"]="Fail";
}
else
{
array_push($ctMsg,"Invalid Image Format");
}
return($ctMsg);
}

public function getPagination($tbl_name,$targetpage,$sqlCondition){
global $page;
//$tbl_name;
$adjacents = 3;

$targetpage;
$limit = 20;

$page=1;
if(empty($_GET['page']))
{$page = 1;}
else
{$page = $_GET['page'];}

if($page)
$start = ($page - 1) * $limit;
else
$start = 0;

$sqlQuery="SELECT * FROM `$tbl_name` $sqlCondition LIMIT $start, $limit";
$sqlQueryRes=mysql_query($sqlQuery)or die(mysql_error());
$query = "SELECT COUNT(*) as num FROM `$tbl_name` $sqlCondition";

$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages['num'];

if ($page == 0) $page = 1;
$prev = $page - 1;
$next = $page + 1;
$lastpage = ceil($total_pages/$limit);
$lpm1 = $lastpage - 1;

$pagination = "";
if($lastpage > 1)
{
$pagination .= "<div class=\"pagination\">";
//previous button
if ($page > 1)
$pagination.= "<a href=\"$targetpage?page=$prev\">&lt;&lt;</a>";
else
$pagination.= "<span class=\"disabled\">&lt;&lt;</span>";

//pages
if ($lastpage < 7 + ($adjacents * 2))//not enough pages to bother breaking it up
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";
}
}
elseif($lastpage > 5 + ($adjacents * 2))//enough pages to hide some
{
//close to beginning; only hide later pages
if($page < 1 + ($adjacents * 2))
{
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";
}
$pagination.= "...";
$pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>";
$pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>";
}
//in middle; hide some front and some back
elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
{
$pagination.= "<a href=\"$targetpage?page=1\">1</a>";
$pagination.= "<a href=\"$targetpage?page=2\">2</a>";
$pagination.= "...";
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";
}
$pagination.= "...";
$pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>";
$pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>";
}
//close to end; only hide early pages
else
{
$pagination.= "<a href=\"$targetpage?page=1\">1</a>";
$pagination.= "<a href=\"$targetpage?page=2\">2</a>";
$pagination.= "...";
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";
}
}
}

//next button
if ($page < $counter - 1)
$pagination.= "<a href=\"$targetpage?page=$next\">&gt;&gt;</a>";
else
$pagination.= "<span class=\"disabled\">&gt;&gt;</span>";
$pagination.= "</div>\n";
}
return(array("pagination"=>$pagination,"sqlQueryRes"=>$sqlQueryRes));
}


/*Assign product list display count starts*/

public function getPagination_limit($tbl_name,$targetpage,$limit, $sqlCondition){
global $page;
//$tbl_name;
$adjacents = 3;

$targetpage;
$limit = $limit;

$page=1;
if(empty($_GET['page']))
{$page = 1;}
else
{$page = $_GET['page'];}

if($page)
$start = ($page - 1) * $limit;
else
$start = 0;

$sqlQuery="SELECT * FROM `$tbl_name` $sqlCondition LIMIT $start, $limit";
$sqlQueryRes=mysql_query($sqlQuery)or die(mysql_error());
$query = "SELECT COUNT(*) as num FROM `$tbl_name` $sqlCondition";

$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages['num'];

if ($page == 0) $page = 1;
$prev = $page - 1;
$next = $page + 1;
$lastpage = ceil($total_pages/$limit);
$lpm1 = $lastpage - 1;

$pagination = "";
if($lastpage > 1)
{
$pagination .= "<div class=\"pagination\">";
//previous button
if ($page > 1)
$pagination.= "<a href=\"$targetpage?page=$prev\">&lt;&lt;</a>";
else
$pagination.= "<span class=\"disabled\">&lt;&lt;</span>";

//pages
if ($lastpage < 7 + ($adjacents * 2))//not enough pages to bother breaking it up
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";
}
}
elseif($lastpage > 5 + ($adjacents * 2))//enough pages to hide some
{
//close to beginning; only hide later pages
if($page < 1 + ($adjacents * 2))
{
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";
}
$pagination.= "...";
$pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>";
$pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>";
}
//in middle; hide some front and some back
elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
{
$pagination.= "<a href=\"$targetpage?page=1\">1</a>";
$pagination.= "<a href=\"$targetpage?page=2\">2</a>";
$pagination.= "...";
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";
}
$pagination.= "...";
$pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>";
$pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>";
}
//close to end; only hide early pages
else
{
$pagination.= "<a href=\"$targetpage?page=1\">1</a>";
$pagination.= "<a href=\"$targetpage?page=2\">2</a>";
$pagination.= "...";
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";
}
}
}

//next button
if ($page < $counter - 1)
$pagination.= "<a href=\"$targetpage?page=$next\">&gt;&gt;</a>";
else
$pagination.= "<span class=\"disabled\">&gt;&gt;</span>";
$pagination.= "</div>\n";
}
return(array("pagination"=>$pagination,"sqlQueryRes"=>$sqlQueryRes));
}

/* Assign product list display counts ends*/



// encrypt
function encrypt($data)
{
$data = strtr($data, $GLOBALS['chars']);
return $data;
}

// decrypt
function decrypt($data)
{
$charset = array_flip($GLOBALS['chars']);
$charset = array_reverse($charset, true);

$data = strtr($data, $charset);
unset($charset);
return $data;
}


public function checkEmail($email)
{
$emFlag=filter_var($email, FILTER_VALIDATE_EMAIL);
return $emFlag;
}
}


function printInfo($info){
foreach($info as $key=>$value)
echo "<br/>$key = $value";
//exit();
}

define('VIEW_IMG',"<img src='images/icon_view.png' border='0' alt='View' title='View' />");
define('EDIT_IMG',"<img src='images/icon_edit.png' border='0' alt='Edit' title='Edit' />");
define('DELETE_IMG',"<img src='images/icon_del.png' border='0' alt='Delete' title='Delete' />");


function clean_url($text)
{
$text=strtolower($text);
$code_entities_match = array('>>','?','–','–','&','"','"','–',"'",'-','–','"','!','@','#','$','%','^','&','*','(',')','_','+','{','}','|',':','"','< ','>','?','[',']','\\',';',"'",',','.','/','*','+','~','`','=','-','ï','Í','–','O', ' ', '&icirc;', '&iacute;');

$_clean_title = str_replace($code_entities_match,"", rtrim(ltrim($text)));
return str_replace(" ","-", $_clean_title);
}
?>

chrisranjana

9:46 am on Jun 13, 2011 (gmt 0)

10+ Year Member



Can you post the source code of Connection.php ?

penders

8:55 am on Jun 14, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Your code is PHP5, but the error suggests your server is running PHP4?!

chadodes

9:13 pm on Jun 16, 2011 (gmt 0)

10+ Year Member



As Chrisranjana's direction says,
The error resides in your connection.php

Change/or star out the domain / user / pass and post that code.

penders

12:09 am on Jun 17, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



As Chrisranjana's direction says,
The error resides in your connection.php


I'm curious, what makes both of you think the code posted is not "Connection.php"? (There's enough of it! :)