Re: News php code
Posted: Wed Mar 28, 2012 1:59 am
What's on line 9?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
Parse error: syntax error, unexpected '<' in /srv/disk4/741839/www/catapultphpmysql.eu.pn/testwebsite/news/add.php on line 32Code: Select all
<html>
<head>
<title>Add News</title>
<meta http-equiv="Content-Type" content="text/html; charset="iso"-8859-1">
</head>
<body>
<?
if (isset($_POST["hiddenField"]) /* still need that add_n thing though so */ && $_POST["hiddenField"] == "add_n") {
$name = $_POST["name"];
$link = @mysql_connect("fdb3.eu.pn", "741839_test", "building10");
if(!$link){
echo('Error connecting to the database: ' . $mysql_error());
exit();
}
$db = @mysql_select_db('741839_test');
if(!$db){
echo('Error selecting database: ' . $mysql_error());
exit();
$query = "INSERT INTO news (name, email, headline, story, timestamp) VALUES ('" . mysql_real_escape_string($name) . "', '" . mysql_real_escape_string($email) . "', '" . mysql_real_escape_string($headline) . "', '" . mysql_real_escape_string($story) . "', NOW())";
if(!$result){
echo('Error adding news: ' . $mysql_error());
exit();
}else{
mysql_close($link);
echo('Success!<br><a href="add.php">Click here</a> to add more news.<br><a href="edit.php">Click here</a> to edit news.<br><a href="../index.php">Click here</a> to return to the main page.');
}
}else{
?>
<?
<form name="form1" method="post" action="<? echo $PHP_SELF; ?>">
<table width="50%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%">Name</td>
<td><input name="name" type="text" id="name"></td>
</tr>
<tr>
<td>Email</td>
<td><input name="email" type="text" id="email"></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Headline</td>
<td><input name="headline" type="text" id="headline"></td>
</tr>
<tr>
<td>News Story</td>
<td><textarea name="story" id="story"></textarea></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input name=$_POST["hiddenField"] == "add_n") {type="hidden" value="add_n">
<input name="add" type="submit" id="add" value="Submit">
</div></td>
</tr>
</table>
</form>
?>
</body>
</html>Code: Select all
Parse error: syntax error, unexpected '<' in /srv/disk4/741839/www/catapultphpmysql.eu.pn/testwebsite/news/add.php on line 30Code: Select all
<html>
<head>
<title>Add News</title>
<meta http-equiv="Content-Type" content="text/html; charset="iso"-8859-1">
</head>
<body>
<?php
if (isset($_POST["hiddenField"]) /* still need that add_n thing though so */ && $_POST["hiddenField"] == "add_n") {
$name = $_POST["name"];
$link = @mysql_connect("", "", "");
if(!$link){
echo('Error connecting to the database: ' . $mysql_error());
exit();
}
$db = @mysql_select_db(');
if(!$db){
echo('Error selecting database: ' . $mysql_error());
exit();
$query = "INSERT INTO news (name, email, headline, story, timestamp) VALUES ('" . mysql_real_escape_string($name) . "', '" . mysql_real_escape_string($email) . "', '" . mysql_real_escape_string($headline) . "', '" . mysql_real_escape_string($story) . "', NOW())";
if(!$result){
echo('Error adding news: ' . $mysql_error());
exit();
}else{
mysql_close($link);
echo('Success!<br><a href="add.php">Click here</a> to add more news.<br><a href="edit.php">Click here</a> to edit news.<br><a href="../index.php">Click here</a> to return to the main page.');
}
}else{
<form name="form1" method="post" action="<? echo $PHP_SELF; ?>">
<table width="50%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%">Name</td>
<td><input name="name" type="text" id="name"></td>
</tr>
<tr>
<td>Email</td>
<td><input name="email" type="text" id="email"></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Headline</td>
<td><input name="headline" type="text" id="headline"></td>
</tr>
<tr>
<td>News Story</td>
<td><textarea name="story" id="story"></textarea></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input name=$_POST["hiddenField"] == "add_n") {type="hidden" value="add_n">
<input name="add" type="submit" id="add" value="Submit">
</td>
</tr></table></form></div>
?>
</body>
</html>