Project4 in PHP Coding Academy

Code junkies hangout here

Moderators: ChrisThornett, LXF moderators

Project4 in PHP Coding Academy

Postby Bryan » Tue Jul 20, 2010 7:12 pm

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>
Bryan
 
Posts: 14
Joined: Tue May 29, 2007 5:18 pm

Re: Project4 in PHP Coding Academy

Postby bobthebob1234 » Tue Jul 20, 2010 8:35 pm

Bryan wrote:print "<li><strong>$task_Name</strong>-$task_Description</li>;
}


You're missing the " at the end of the line.

Should be
Code: Select all
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
User avatar
bobthebob1234
LXF regular
 
Posts: 1370
Joined: Thu Jan 03, 2008 9:38 pm
Location: A hole in a field

Gedit + Project4

Postby Bryan » Wed Jul 21, 2010 3:58 pm

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!
Bryan
 
Posts: 14
Joined: Tue May 29, 2007 5:18 pm

Postby bobthebob1234 » Wed Jul 21, 2010 6:19 pm

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
User avatar
bobthebob1234
LXF regular
 
Posts: 1370
Joined: Thu Jan 03, 2008 9:38 pm
Location: A hole in a field

Refresh question PHP project 4 coding academy

Postby madoba » Wed Jul 06, 2011 2:04 pm

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.
madoba
 
Posts: 14
Joined: Wed Jul 06, 2011 1:50 pm
Location: San Angelo, Texas, USA


Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests