| View previous topic :: View next topic |
| Author |
Message |
Bryan
Joined: Tue May 29, 2007 6:18 pm Posts: 14
|
Posted: Tue Jul 20, 2010 8:12 pm Post subject: Project4 in PHP Coding Academy |
|
|
When running the script up to and including page 63 I get the following error message:
bryan@Second:~$ cd /var/www
bryan@Second:/var/www$ php project4.php
PHP Parse error: syntax error, unexpected '/' in /var/www/project4.php on line 19
bryan@Second:/var/www$
I have tried amending the lines adjacent to line 19 but without success.
Have I made a mistake or is there a printing error in the booklet?
This is my code listing:
<?php
mysql_connect("localhost", "root", "bryan");
msql_select_db("testing");
if(isset($_POST["task_name"])){
$task_name=$_POST["task_name"];
$task_description=$_POST["task_description"];
$task_name=mysql_real_escape_string($task_name);
$task_description=mysql_real_escape_($task_description);
mysql_query("insert into todo(Name,Description)values ('$task_name', '$task_description');");
}
$tasks=mysql_query("select ID, Name, Description from todo;");
if(msql_num_rows($tasks)){
print "<h1>Existing tasks</h>";
print "<ul>";
while($task=mysql_fetch_assoc($tasks)) {
extract($task, EXTR_PREFIX_ALL, "task");
print "<li><strong>$task_Name</strong>-$task_Description</li>;
}
print "</ul>";
}
?>
<h1>Add new task</h1>
<form method="post" action="project4.php">
<p>Name it:<input type="text" name="task_name" /> </p>
<p>Describe it: <input type="text" name="task_description" /> </p>
<input type="submit" value="Add" />
</form> |
|
| Back to top |
|
 |
bobthebob1234 LXF regular

Joined: Thu Jan 03, 2008 9:38 pm Posts: 1356 Location: A hole in a field
|
Posted: Tue Jul 20, 2010 9:35 pm Post subject: Re: Project4 in PHP Coding Academy |
|
|
| Bryan wrote: |
print "<li><strong>$task_Name</strong>-$task_Description</li>;
}
|
You're missing the " at the end of the line.
Should be
| Code: | | print "<li><strong>$task_Name</strong>-$task_Description<li>"; |
Just out of interest what text editor are you using. I just pasted your code into gedit on ubuntu, turned on highlighting and then I could instantly see that there was a " missing because of the different highlighting. _________________ For certain you have to be lost to find the places that can't be found. Elseways, everyone would know where it was |
|
| Back to top |
|
 |
Bryan
Joined: Tue May 29, 2007 6:18 pm Posts: 14
|
Posted: Wed Jul 21, 2010 4:58 pm Post subject: Gedit + Project4 |
|
|
Thank you for taking the time to spot my error.
At age 78 my observation skills are not quite as good as they used to be! |
|
| Back to top |
|
 |
bobthebob1234 LXF regular

Joined: Thu Jan 03, 2008 9:38 pm Posts: 1356 Location: A hole in a field
|
Posted: Wed Jul 21, 2010 7:19 pm Post subject: |
|
|
I missed it as well when i was reading your post. It was only when I got the highlighting up that I saw that there was something wrong! _________________ For certain you have to be lost to find the places that can't be found. Elseways, everyone would know where it was |
|
| Back to top |
|
 |
madoba
Joined: Wed Jul 06, 2011 2:50 pm Posts: 14 Location: San Angelo, Texas, USA
|
Posted: Wed Jul 06, 2011 3:04 pm Post subject: Refresh question PHP project 4 coding academy |
|
|
I've completed project 4 and now have a question about it?
When I submit an item for the todo list and wait for the page to post back and then refresh or postback the page, the item is added into the database again. Why does this happen and How do I prevent this behavior? The project just doesn't seem complete without addressing this problem. |
|
| Back to top |
|
 |
| View previous topic :: View next topic |
|