Проблем със php код ДАВА ГРЕШКА?!

talevtehnology

Registered
Показва ми следната грешка :

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/talevteh/public_html/tutorials_admin.php on line 20

ето го и кода:
Код:
<?php 
//------------------------------------------ 
//database connection 
mysql_connect("localhost", "talevteh_talev", "********") or die(mysql_error()); 
mysql_select_db("talevteh_obqvi") or die(mysql_error()); 
//end database connection 
//------------------------------------------ 


//------------[IMPORTANT]------------------- 
// I would suggest adding this file to part 
// of a user system so it doesn't get viewed 
// by just anyone 
//------------[IMPORTANT]------------------- 


//------------------------------------------ 
//echo out a navigation panel 
echo " 
<center><a href="tutorials.php">View Categorys</a> | <a href="tutorials.php?action=addtutorial">Add Tutorial</a> | <a href="tutorials_admin.php">Admin</a> | <a href="tutorials_admin.php?action=addcategory">Add Category</a></center> 
"; 
//------------------------------------------ 

//------------------------------------------ 
//begin main navigation (tutorials.php?action=) 
switch($_GET['action']) 
{ 
//-------------------------- 
// case to add a tutorial category 
//-------------------------- 
case "addcategory": 
//if the form to add a new category 
//isn't submitted, show one 
if(!isset($_POST['new_category'])) 
{ 
echo " 
<form action='tutorials_admin.php?action=addcategory' method='post'> 
<table border='0' cellpadding='0' cellspacing='0' width='500'> 
<tr> 
<td>Category name:</td> 
<td><input type='text' name='category' maxlength='25'></td> 
</tr> 
<tr> 
<td>Description:</td> 
<td><textarea name='description' cols='40' rows='10'></textarea></td> 
</tr> 
<tr> 
<td colspan='2'><center><input type='submit' name='new_category' value='New Category!'></td> 
</tr> 
</table> 
</form> 
"; 
} 
//else, error check and then insert data to database! 
elseif(isset($_POST['new_category'])) 
{ 
$category = mysql_real_escape_string(strip_tags($_POST['category'])); 
$description = mysql_real_escape_string(strip_tags($_POST['description'])); 

//begin error reporting 
$error_msg = array(); 
if(empty($category)) 
{ 
$error_msg[] = "No Category name entered!<br />"; 
} 
if(empty($description)) 
{ 
$error_msg[] = "No description entered!<br />"; 
} 
//print errors, if any 
if(count($error_msg)>0) 
{ 
echo "<strong>ERROR:</strong><br>n"; 
foreach($error_msg as $err) 
echo "$err"; 
} 
//else, no errors, insert to the DB! 
else 
{ 
$query = mysql_query("INSERT INTO tutorials_categorys (category, description) VALUES ('$category', '$description')") or die(mysql_error()); 
echo "Tutorial Category Added!"; 
} 
} 
break; 

//-------------------------- 
//this case takes the submitted 
//form data of the admin form. 
//you can either validate, or delete 
//-------------------------- 
case "handle": 
//if nothing is submitted in the 
//row[] array, then error! 
if(empty($_POST['row'])) 
{ 
echo "Nothing to delete/validate!"; 
} 
if(isset($_POST['delete_tutorials'])) 
{ 
$delete_array = $_POST['row']; 

//loop through each individual 
//item in the array 

foreach($delete_array as $val) 
{ 
//delete them! 
$query = "DELETE FROM tutorials WHERE id = '$val'"; 
$result = mysql_query($query) or die(mysql_error()); 
} 
echo "Tutorial(s) deleted"; 
} 
elseif(isset($_POST['validate_tutorials'])) 
{ 
$validate_array = $_POST['row']; 

//loop through each individual 
//item in the array 

foreach($validate_array as $val) 
{ 
//update the status to 1 which means validated! 
$query = "UPDATE tutorials SET is_validated = '1' WHERE id = '$val'"; 
$result = mysql_query($query) or die(mysql_error()); 
} 
echo "Tutorial(s) validated!"; 
} 
break; 

//-------------------------- 
//default case, we show 
//all tutorials with actions 
//-------------------------- 
default: 
$query = mysql_query("SELECT * FROM tutorials WHERE is_validated = '0' ORDER BY time_submitted DESC") or die(mysql_error()); 
echo "<h1>Unreviewed Tutorials</h1>"; 
if(mysql_num_rows($query) == 0) 
{ 
echo "No tutorials unreviewed!"; 
} 
//there are rows, show the tutorials to 
//verify them 
else 
{ 
//echo the submit buttons 
echo " 
<form action='tutorials_admin.php?action=handle' method='post'> 
<table border='0' cellpadding='0' cellspacing='0' width='500'> 
<tr> 
<td><center>With Selected</center></td> 
</tr> 
<tr> 
<td colspan='2'><center><input type='submit' name='validate_tutorials' value='Validate'><input type='submit' name='delete_tutorials' value='Delete'></center></td> 
</tr> 
<tr> 
<td colspan='2'><hr /></td> 
</tr> 
"; 
//loop throught it to show them all 
while($row = mysql_fetch_array($query)) 
{ 
echo " 
<tr> 
<td>Title:</td> 
<td>$row[title]</td> 
</tr> 
<tr> 
<td>Submitter:</td> 
<td>$row[submitter]</td> 
</tr> 
<tr> 
<td>Short Description:</td> 
<td>$row[short_description]</td> 
</tr> 
<tr> 
<td>Tutorial Text:</td> 
<td>$row[text]</td> 
</tr> 
<tr> 
<td>Email:</td> 
<td><a href='mailto:$row[email]'>$row[email]</a></td> 
</tr> 
<tr> 
<td><b>Mark</b></td> 
<td><input type='checkbox' name='row[]' value='$row[id]'></td> 
</tr> 
<tr> 
<td colspan='2'><hr /></td> 
</tr> 
"; 
} 
echo " 
</table> 
"; 
} 
break; 
} 
?>

Моля ви помагайте!!!
greshka.jpg


На този ред показва че има грешка
 
Код:
<?php 
//------------------------------------------ 
//database connection 
mysql_connect("localhost", "talevteh_talev", "********") or die(mysql_error()); 
mysql_select_db("talevteh_obqvi") or die(mysql_error()); 
//end database connection 
//------------------------------------------ 


//------------[IMPORTANT]------------------- 
// I would suggest adding this file to part 
// of a user system so it doesn't get viewed 
// by just anyone 
//------------[IMPORTANT]------------------- 


//------------------------------------------ 
//echo out a navigation panel 
echo "
<center><a href='tutorials.php'>View Categorys</a> | <a href='tutorials.php?action=addtutorial'>Add Tutorial</a> | <a href='tutorials_admin.php'>Admin</a> | <a href='tutorials_admin.php?action=addcategory'>Add Category</a></center>
";
//------------------------------------------ 

//------------------------------------------ 
//begin main navigation (tutorials.php?action=) 
switch($_GET['action']) 
{ 
//-------------------------- 
// case to add a tutorial category 
//-------------------------- 
case "addcategory": 
//if the form to add a new category 
//isn't submitted, show one 
if(!isset($_POST['new_category'])) 
{ 
echo " 
<form action='tutorials_admin.php?action=addcategory' method='post'> 
<table border='0' cellpadding='0' cellspacing='0' width='500'> 
<tr> 
<td>Category name:</td> 
<td><input type='text' name='category' maxlength='25'></td> 
</tr> 
<tr> 
<td>Description:</td> 
<td><textarea name='description' cols='40' rows='10'></textarea></td> 
</tr> 
<tr> 
<td colspan='2'><center><input type='submit' name='new_category' value='New Category!'></td> 
</tr> 
</table> 
</form> 
"; 
} 
//else, error check and then insert data to database! 
elseif(isset($_POST['new_category'])) 
{ 
$category = mysql_real_escape_string(strip_tags($_POST['category'])); 
$description = mysql_real_escape_string(strip_tags($_POST['description'])); 

//begin error reporting 
$error_msg = array(); 
if(empty($category)) 
{ 
$error_msg[] = "No Category name entered!<br />"; 
} 
if(empty($description)) 
{ 
$error_msg[] = "No description entered!<br />"; 
} 
//print errors, if any 
if(count($error_msg)>0) 
{ 
echo "<strong>ERROR:</strong><br>n"; 
foreach($error_msg as $err) 
echo "$err"; 
} 
//else, no errors, insert to the DB! 
else 
{ 
$query = mysql_query("INSERT INTO tutorials_categorys (category, description) VALUES ('$category', '$description')") or die(mysql_error()); 
echo "Tutorial Category Added!"; 
} 
} 
break; 

//-------------------------- 
//this case takes the submitted 
//form data of the admin form. 
//you can either validate, or delete 
//-------------------------- 
case "handle": 
//if nothing is submitted in the 
//row[] array, then error! 
if(empty($_POST['row'])) 
{ 
echo "Nothing to delete/validate!"; 
} 
if(isset($_POST['delete_tutorials'])) 
{ 
$delete_array = $_POST['row']; 

//loop through each individual 
//item in the array 

foreach($delete_array as $val) 
{ 
//delete them! 
$query = "DELETE FROM tutorials WHERE id = '$val'"; 
$result = mysql_query($query) or die(mysql_error()); 
} 
echo "Tutorial(s) deleted"; 
} 
elseif(isset($_POST['validate_tutorials'])) 
{ 
$validate_array = $_POST['row']; 

//loop through each individual 
//item in the array 

foreach($validate_array as $val) 
{ 
//update the status to 1 which means validated! 
$query = "UPDATE tutorials SET is_validated = '1' WHERE id = '$val'"; 
$result = mysql_query($query) or die(mysql_error()); 
} 
echo "Tutorial(s) validated!"; 
} 
break; 

//-------------------------- 
//default case, we show 
//all tutorials with actions 
//-------------------------- 
default: 
$query = mysql_query("SELECT * FROM tutorials WHERE is_validated = '0' ORDER BY time_submitted DESC") or die(mysql_error()); 
echo "<h1>Unreviewed Tutorials</h1>"; 
if(mysql_num_rows($query) == 0) 
{ 
echo "No tutorials unreviewed!"; 
} 
//there are rows, show the tutorials to 
//verify them 
else 
{ 
//echo the submit buttons 
echo " 
<form action='tutorials_admin.php?action=handle' method='post'> 
<table border='0' cellpadding='0' cellspacing='0' width='500'> 
<tr> 
<td><center>With Selected</center></td> 
</tr> 
<tr> 
<td colspan='2'><center><input type='submit' name='validate_tutorials' value='Validate'><input type='submit' name='delete_tutorials' value='Delete'></center></td> 
</tr> 
<tr> 
<td colspan='2'><hr /></td> 
</tr> 
"; 
//loop throught it to show them all 
while($row = mysql_fetch_array($query)) 
{ 
echo " 
<tr> 
<td>Title:</td> 
<td>$row[title]</td> 
</tr> 
<tr> 
<td>Submitter:</td> 
<td>$row[submitter]</td> 
</tr> 
<tr> 
<td>Short Description:</td> 
<td>$row[short_description]</td> 
</tr> 
<tr> 
<td>Tutorial Text:</td> 
<td>$row[text]</td> 
</tr> 
<tr> 
<td>Email:</td> 
<td><a href='mailto:$row[email]'>$row[email]</a></td> 
</tr> 
<tr> 
<td><b>Mark</b></td> 
<td><input type='checkbox' name='row[]' value='$row[id]'></td> 
</tr> 
<tr> 
<td colspan='2'><hr /></td> 
</tr> 
"; 
} 
echo " 
</table> 
"; 
} 
break; 
} 
?>

така ?
 

Back
Горе