Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Project4 in PHP Coding Academy

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
Bryan



Joined: Tue May 29, 2007 6:18 pm
Posts: 14

PostPosted: Tue Jul 20, 2010 8:12 pm    Post subject: Project4 in PHP Coding Academy Reply with quote

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
View user's profile Send private message
bobthebob1234
LXF regular


Joined: Thu Jan 03, 2008 9:38 pm
Posts: 1369
Location: A hole in a field

PostPosted: Tue Jul 20, 2010 9:35 pm    Post subject: Re: Project4 in PHP Coding Academy Reply with quote

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
View user's profile Send private message
Bryan



Joined: Tue May 29, 2007 6:18 pm
Posts: 14

PostPosted: Wed Jul 21, 2010 4:58 pm    Post subject: Gedit + Project4 Reply with quote

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
View user's profile Send private message
bobthebob1234
LXF regular


Joined: Thu Jan 03, 2008 9:38 pm
Posts: 1369
Location: A hole in a field

PostPosted: Wed Jul 21, 2010 7:19 pm    Post subject: Reply with quote

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
View user's profile Send private message
madoba



Joined: Wed Jul 06, 2011 2:50 pm
Posts: 14
Location: San Angelo, Texas, USA

PostPosted: Wed Jul 06, 2011 3:04 pm    Post subject: Refresh question PHP project 4 coding academy Reply with quote

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 user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast