...

View Full Version : unexpected ;



rafiki
04-02-2007, 06:20 PM
Parse error: parse error, unexpected ';' in C:\Program Files\xampp\xampp\xampp\htdocs\ctut\added.php on line 49
is the error

<?php
include 'mysql_connect.php';
$errors = array("You haven't entered a title or the tutorial", "You haven't entered a valid link for the tutorial", "You haven't entered you name");
$error = '';
if (!isset($_POST['title'])) {
$error = $errors[0];
}

if (!isset($_POST['link'])) {
$error .= $errors[1]; //this line is giving error
}

if (!isset($_POST['author'] {
$error .= $errors[2];
}
if ($error != '') {
die($error);
}else{
$i = $_POST['catid']
switch ($i) {
case "HTML":
$cat_id = 1;
break;
case "CSS":
$cat_id = 2;
break;
case "Javascript":
$cat_id = 3;
break;
case "PHP":
$cat_id = 4;
break:
case "MYSQL" :
$cat_id = 4;
break:
case "Photoshop" :
$cat_id = 5
break:
case "Flash" :
$cat_id = 6;
break:
} is some of the PHP code

Nightfire
04-02-2007, 06:28 PM
Missing closing brackets


if (!isset($_POST['author'])) {

You're missing loads of semi-colons


$i = $_POST['catid'];
switch ($i) {
case "HTML":
$cat_id = 1;
break;
case "CSS":
$cat_id = 2;
break;
case "Javascript":
$cat_id = 3;
break;
case "PHP":
$cat_id = 4;
break;
case "MYSQL" :
$cat_id = 4;
break;
case "Photoshop" :
$cat_id = 5;
break;
case "Flash" :
$cat_id = 6;
break;
}

rafiki
04-02-2007, 06:32 PM
tyvm i havent had much sleep and surviving on coffee alone :( pos rep added
or not it wont let me because your the last user i gave it too :(

neel_basu
04-02-2007, 07:46 PM
You were missing lots of semicolons and parenthesis
Here is the code after Correction

<?php
include 'mysql_connect.php';
$errors = array("You haven't entered a title or the tutorial", "You haven't entered a valid link for the tutorial", "You haven't entered you name");
$error = '';
if (!isset($_POST['title'])) {
$error = $errors[0];
}

if (!isset($_POST['link'])) {
$error .= $errors[1]; //this line is giving error
}

if (!isset($_POST['author']))
{
$error .= $errors[2];
}
if ($error != '')
{
die($error);
}
else
{
$i = $_POST['catid'];
switch ($i) {
case "HTML":
$cat_id = 1;
break;
case "CSS":
$cat_id = 2;
break;
case "Javascript":
$cat_id = 3;
break;
case "PHP":
$cat_id = 4;
break;
case "MYSQL" :
$cat_id = 4;
break;
case "Photoshop" :
$cat_id = 5;
break;
case "Flash" :
$cat_id = 6;
break;
}
}Add a default case

rafiki
04-02-2007, 07:55 PM
that page is working correctly now
this is my new error

Parse error: parse error, unexpected $end in C:\Program Files\xampp\xampp\xampp\htdocs\staceyfenton\contact.php on line 119



<?php
if ($_GET['action'] == send)
{
$to = "naughtydevilstacey@hotmail.co.uk";
$subject = "Modelling";
$message = $_POST['message'];
$message .= $_POST['from'];
if(md5($_POST['code']) != $_SESSION['key'])
{
die("Error: You must enter the code correctly"); //code for incorrect input
}else{
$mail = mail($to, $subject, $message);
if ($mail) {
echo "mail sent please await a reply";
}else{
echo "error sending mail please try later";
}
}
}else{
echo '<form action="contact.php?action=send" method="post">';
echo '<input type="text" name="from" value=""/>';
echo '<textarea rows=10 cols=60>Enter you message here</textarea">';
include'captcha.php';
echo "<input type=text name=code /> Enter the code you see in the image";
?>

thats all the php apart from at the very top of the page i have
session_start()

page 119 is the last line of my whole file
as you may have guessed

</body></html>

iLLin
04-02-2007, 07:58 PM
Your missing your last }

Nightfire
04-02-2007, 08:00 PM
No closing curly bracket


}else{
echo '<form action="contact.php?action=send" method="post">';
echo '<input type="text" name="from" value=""/>';
echo '<textarea rows=10 cols=60>Enter you message here</textarea">';
include'captcha.php';
echo "<input type=text name=code /> Enter the code you see in the image";
}
?>

Read the error and look through your code, you're making silly mistakes that shouldn't happen if you took your time ;)

neel
04-02-2007, 08:01 PM
Ya Last } of Else
Did you added the default case ??

rafiki
04-02-2007, 08:19 PM
ty again
no the default case is photoshop :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum