Page 2 of 2

Re: News php code

Posted: Wed Mar 28, 2012 1:59 am
by requinix
What's on line 9?

Re: News php code

Posted: Wed Mar 28, 2012 5:44 am
by Shychild
ok...

pls check if i am correct.:)

there's still prob.

Code: Select all

Parse error: syntax error, unexpected '<' in /srv/disk4/741839/www/catapultphpmysql.eu.pn/testwebsite/news/add.php on line 32

Code: 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>&nbsp;</td>
      <td>&nbsp;</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>
pls help me. thnx.

Re: News php code

Posted: Wed Mar 28, 2012 1:53 pm
by requinix
What's on line 31?

Re: News php code

Posted: Wed Mar 28, 2012 11:47 pm
by Shychild
problem again.

Code: Select all

Parse error: syntax error, unexpected '<' in /srv/disk4/741839/www/catapultphpmysql.eu.pn/testwebsite/news/add.php on line 30
new code

Code: 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>&nbsp;</td>
      <td>&nbsp;</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>
pls help me requinix. thanks a lot!

Re: News php code

Posted: Thu Mar 29, 2012 10:33 am
by requinix
Last time I'm going to answer a silly question like this.

What's not on line 30?

Re: News php code

Posted: Fri Apr 13, 2012 1:13 am
by deragoku
To prove that you can find like the small things. Therefore, trying to find these things too much, okay?