PDA

View Full Version : Parse error???



shachi
09-25-2005, 02:59 PM
I wanted to create a shout box,
I created 4 files: shoutbox.php, connect.php, show_shout.php and box.htm.
--------------------------------------------------------------------------------------------------------
shoutbox.php:


<?php
include("connect.php")
if(isset($_POST["posted"]))
{
$name = $_POST["name"];
$message = $_POST["message"];
$time = time();
$ip = $_SERVER["REMOTE_ADDR"]
$check_name_length = strlen($name); // checks length
$check_message_length = strlen($message); // checks length
If($check_name_length => 30) || if($check_message_length => 250) // if statements for length
{
echo "Please fill in the textboxes properly.";
}
else {
mysql_query("INSERT INTO shoutbox( id, ip, name, time, message) VALUES ("NULL","$ip", "$name", "$time", "$message")") or die ("Failed to add shout");
}
}
?>
--------------------------------------------------------------------------------------------------------
connect.php:


<?php
$connect = mysql_connect("localhost","shachi","thisistest") or die("Failed to connect to host")
$db = mysql_select_db("freemys_shachi") or die("Failed to connect to database");
?>
--------------------------------------------------------------------------------------------------------
show_shout.php:


<?php
include("connect.php");
$query = Mysql_query("SELECT * FROM shoutbox DESC id LIMIT 5");
while($r = Mysql_fetch_array($query)
{
$time = $r["time"];
$name = $r["name"];
$message = $r["message"];
}

echo "Shout by $name at $time:";
echo $message;
?>
--------------------------------------------------------------------------------------------------------
box.htm:


<html>
<body>
<form method="POST" action="shoutbox.php">
Name: <input type="text" name="name"> <!--//field with the name "name"--><br>
Message <input type="text" name="message"> <!--//field with the name "message"--><br>
<input type="hidden" name="posted" value="true"> <!--// hidden form field containing value "true"--><br>
<input type="submit" value="Shout!">
</body>
</html>
--------------------------------------------------------------------------------------------------------

When I tried to post from box.htm it shows a parse error:

Parse error: parse error, unexpected T_IF in /var/www/shoutbox.php on line 3

I don't know what the problem is, someone plz help. :confused:

Twey
09-25-2005, 03:37 PM
$ip = $_SERVER["REMOTE_ADDR"]
You missed a semicolon.

shachi
09-26-2005, 02:00 AM
It's still saying the same parse error:

Parse error: parse error, unexpected T_IF in /var/www/shoutbox.php on line 3

mwinter
09-26-2005, 02:10 AM
It's still saying the same parse error:You did the same thing in connect.php when calling the mysql_connect function.

Mike

shachi
09-26-2005, 10:51 AM
You did the same thing in connect.php when calling the mysql_connect function.

Mike

I actually didn't get you. Can you make this a little clear for me please?

Twey
09-26-2005, 03:39 PM
include("connect.php")
You missed one there, too.

$connect = mysql_connect("localhost","shachi","thisistest") or die("Failed to connect to host")
And there.


mysql_query("INSERT INTO shoutbox( id, ip, name, time, message) VALUES ("NULL","$ip", "$name", "$time", "$message")") or die ("Failed to add shout");
You need to escape those quotes:

mysql_query("INSERT INTO shoutbox( id, ip, name, time, message) VALUES (\"NULL\",\"$ip\", \"$name\", \"$time\", \"$message\")") or die ("Failed to add shout");

shachi
09-27-2005, 03:26 PM
Thanks Twey but I got another problem there.
It shows another parse error:


Parse error: parse error, unexpected T_DOUBLE_ARROW in /var/www/shoutbox.php on line 11

Line no. 11: If($check_name_length => 30) || if($check_message_length => 250) // if statements for length

Twey
09-27-2005, 04:58 PM
The operator is >=. => means something rather different.

cr3ative
09-27-2005, 05:35 PM
"The operator is >=. => means something rather different."

Sad face and happy face, obviously.
-cr3

The_Saints1
10-21-2007, 12:07 PM
The operator is >=. => means something rather different.


Dear Twey, Thanx for being so helpful. U're the man.
Ok please help me when u finnish with the girl .

my error is : Parse error: parse error, unexpected $end in C:\Domains\nurusyifa.com\wwwroot\wp-content\themes\wp-andreas01-12\index.php on line 52

It appear after i make some adjustment on header wordpress ...and such.

please help me solve this dear mates and forumner. trillion thanxs in advance

thetestingsite
10-21-2007, 03:42 PM
That parse error means that you either missed a closing bracket, semicolon, etc. It's hard to tell you what to fix if we don't have the code. Please post the code so that we can help you further.

Hope this helps.

The_Saints1
11-13-2007, 06:57 PM
That parse error means that you either missed a closing bracket, semicolon, etc. It's hard to tell you what to fix if we don't have the code. Please post the code so that we can help you further.

Hope this helps.


Dear Pal, this is the code and could you please tell me what missing? very much appreciated. This is the header code. The next post after this is the footer. Tq for teaching.

<head><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="forex,finance,trading, trader online,investment,loan, mortgage, cash online,
making money,adwords, adsense" content="text/html; charset=<?php bloginfo('charset'); ?>" />
<meta name="description" content="<?php bloginfo('name'); ?> - <?php bloginfo('description'); ?>" />
<meta name="keywords" content="" />
<link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" />
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<title><?php bloginfo('name'); wp_title(); ?></title>
<?php wp_head(); ?>
</head>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<body>
<script type='text/javascript' src='http://track3.mybloglog.com/js/jsserv.php?mblID=2007032920273844'></script>
<div id="wrap">

<!--
<div id="header">
<h1><a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a></h1>
<p><strong><?php bloginfo('description'); ?></strong></p>
</div>
-->

<img id="frontphoto" src="<?php bloginfo('template_directory'); ?>/img/front.jpg" width="760" height="175" alt="" />

<p align=center>
<script type="text/javascript"><!--
google_ad_client = "pub-3684802826311457";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "image";
google_ad_channel = "";
google_color_border = "CC0000";
google_color_bg = "FFFFCC";
google_color_link = "CC0000";
google_color_text = "000000";
google_color_url = "3D81EE";
//--></script>

<script type="text/javascript"><!--<p align=center><p align=center>
google_ad_client = "pub-3684802826311457";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text_image";
//2007-10-27: Forex, Financial, Investment, homebusiness, loan
google_ad_channel = "6908781396+9166596418+0136310777+3165203788+9984693700";
google_color_border = "FFFF66";
google_color_bg = "9D1961";
google_color_link = "00FF80";
google_color_text = "66B5FF";
google_color_url = "FFFFFF";
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<?
srand(time());
$random = 0; /*(rand()%2);*/

if ($random == 0){
?>

<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<script type="text/javascript"><!--
google_ad_client = "pub-3684802826311457";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text_image";
//2007-10-22: Financial, Investment, Forex, homebusiness, loan
google_ad_channel = "9166596418+0136310777+6908781396+3165203788+9984693700";
google_color_border = "6131BD";
google_color_bg = "000000";
google_color_link = "FFFF66";
google_color_text = "00FF80";
google_color_url = "FF6FCF";
google_ui_features = "rc:0";
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<?
}
else
{
?>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<script type="text/javascript"><!--
google_ad_client = "pub-3684802826311457";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_ad_channel = "";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "FF0000";
google_color_text = "000000";
google_color_url = "000000";
//--></script>
<?
}
?>

<script type="text/javascript"><!--
google_ad_client = "pub-3684802826311457";
google_ad_width = 728;
google_ad_height = 15;
google_ad_format = "728x15_0ads_al";
//2007-10-27: Forex, Financial, Investment, homebusiness, loan
google_ad_channel = "6908781396+9166596418+0136310777+3165203788+9984693700";
google_color_border = "000000";
google_color_bg = "3D81EE";
google_color_link = "FFFF66";
google_color_text = "66B5FF";
google_color_url = "FFFFFF";
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

</p>

<div id="leftside">

<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('Main Sidebar') ) : else : ?>

<h2 class="hide">Main menu:</h2>
<ul class="page">
<?php if (is_page()) { $highlight = "page_item"; } else {$highlight = "page_item current_page_item"; } ?>
<li class="<?php echo $highlight; ?>"><a href="<?php bloginfo('url'); ?>">Home</a></li>
<?php wp_list_pages('sort_column=menu_order&depth=1&title_li='); ?>
<li ><?php wp_loginout(); ?></li>
</ul>

<?php endif; ?>

<p id="<?php echo $highlight; ?>">

<script type="text/javascript"><!--
auctionads_ad_client = "e9a00afe98370e4654f3";
auctionads_ad_campaign = "";
auctionads_ad_width = "160";
auctionads_ad_height = "600";
auctionads_ad_kw = "digital camera;mp3;money";
auctionads_color_border = "FFFFFF";
auctionads_color_bg = "FFFFFF";
auctionads_color_heading = "00A0E2";
auctionads_color_text = "000000";
auctionads_color_link = "008000";
auctionads_options = "n";
--></script>
<script type="text/javascript" src="http://ads.auctionads.com/pagead/show_ads.js">
</script>




</p>



</div>

The_Saints1
11-13-2007, 07:02 PM
THIS IS THE 404 TEMPLATE
Please tell me where shall i put this code after it is accidentally deleted by me....sigh....tq pal very much.

Plus admin of this site i will delete the code after it is solve or not after this ok. i dont like spamming

<?php get_header(); ?>
<?php get_sidebar(); ?>

<div id="content">
<div class="post">
<h2>Error 404 - Page not found!</h2>
<p>The page you trying to reach does not exist, or has been moved. Please use the menus or the search box to find what you are looking for.</p>
<p>Go Back HomePage <a href="http://www.NexGWeb.com">www.NexGWeb.com</a> </p>
</div>
</div>

<?php get_footer(); ?>