Jump to content

Recommended Posts

Hi there can anyoneplease chek my code and say why php is displaying this error
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Parse error: parse error, unexpected '{', expecting '(' in G:\www\Apache2\public\admin\add.php on line 14[/quote]
Code:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?php

$db_username = "*****";
$db_pasword = "*****";
$db_host = "******";
$db = "news";
@mysql_connect($db_host, $db_username, $db_pasword) or die("Can't connect to database!");
@mysql_select_db($db) or die("Can't select database!");

if ( $_POST[title] == "" || $_POST[date] == "" )
{
echo "Some fields were left blank!";
}
elseif { $_POST[new] == "" }
{
echo "You didn't entered the new!";
}
else
{
$query="INSERT INTO news (title,date,new,short_news) VALUES ('$_POST[title]','$_POST[date]','$_POST[new]','$_POST[short_new]')";
if(!mysql_db_query($db,$query)) die(mysql_error());
echo "News added succesfully!";
}

?>
[/quote]
thanks!
Link to comment
https://forums.phpfreaks.com/topic/11332-what-is-wrong/
Share on other sites

oh ... [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] ... dumb ass me ... but now i'm getting this error
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
Parse error: parse error, unexpected T_ECHO in G:\www\Apache2\public\admin\add.php on line 12[/quote]
no sense to me what is t_echo ... ? any help another time?
Link to comment
https://forums.phpfreaks.com/topic/11332-what-is-wrong/#findComment-42468
Share on other sites

i thought that it's not obligatory... but it's something in this line i think because it's 12 line
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]echo "Some fields were left blank!";[/quote]
sorry for so much questions but i really want to figure it out :)
Link to comment
https://forums.phpfreaks.com/topic/11332-what-is-wrong/#findComment-42503
Share on other sites

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] <?php

$db_username = "*****";
$db_pasword = "*****";
$db_host = "******";
$db = "news";
@mysql_connect($db_host, $db_username, $db_pasword) or die("Can't connect to database!");
@mysql_select_db($db) or die("Can't select database!");

if ( $_POST['title'] == "" || $_POST['date'] == "" )
(
echo "Some fields were left blank!";
)
elseif ( $_POST['new'] == "" )
(
echo "You didn't entered the new!";
)
else
(
$query="INSERT INTO news (title,date,new,short_news) VALUES ('$_POST['title']','$_POST['date']','$_POST['new']','$_POST['short_new']')";
if(!mysql_db_query($db,$query)) die(mysql_error());
echo "News added succesfully!";
)

?>[/quote]
Link to comment
https://forums.phpfreaks.com/topic/11332-what-is-wrong/#findComment-42516
Share on other sites

Whoa whoa whoa... change it to this:
[code]
if ( $_POST['title'] == "" || $_POST['date'] == "" )
{
echo "Some fields were left blank!";
}
elseif ( $_POST['new'] == "" )
{
echo "You didn't entered the new!";
}
else
{
$query="INSERT INTO news (title,date,new,short_news) VALUES ('$_POST['title']','$_POST['date']','$_POST['new']','$_POST['short_new']')";
if(!mysql_db_query($db,$query)) die(mysql_error());
echo "News added succesfully!";
}

?>[/code]

Parenthesis around the evaluation statement, brackets around the if contents.
Link to comment
https://forums.phpfreaks.com/topic/11332-what-is-wrong/#findComment-42517
Share on other sites

thanks for the advices i've just realised that it was strupid to first do connection to database and then check for empty fields ... i've made first check and then connection and query ... and no errors [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /]
cheers!
Link to comment
https://forums.phpfreaks.com/topic/11332-what-is-wrong/#findComment-42692
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.