PHP/MySQL Newbie Quesion

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
spring85195
Forum Newbie
Posts: 1
Joined: Tue Oct 07, 2003 10:17 am

PHP/MySQL Newbie Quesion

Post by spring85195 »

I have follow a tutorial web site and got some code, when I paste and run it on the http://webmaster.lycos.co.uk/spring85195/, it just keep coming up the error message pasted below.


Warning: Unexpected character in input: ''' (ASCII=92) state=1 in /data/members/free/tripod/uk/s/p/r/spring85195/htdocs/guestbook.php on line 5

Parse error: parse error in /data/members/free/tripod/uk/s/p/r/spring85195/htdocs/guestbook.php on line 5




Here is the code of my impession.html


<br><br><br><br><br><br><br><br><br><br>

<html>
<head><title>PHP workshop on form management: impressions.html</title><head>
<body>



<form method="post" action="guestbook.php">
Your name : <input type="text" name="nom"><br>
Your e-mail : <input type="email" name="email"><br>
Did you <input type="radio" name="impression" value="aime"> lode
<input type="radio" name="impression" value="pasaime"> or not this Website.
<br>
Your comments : <textarea name="commentaires"></textarea>
<br><br>
<input type="submit" name="valider" value="Send">
</form>



</body>
</html>






Here is the guestbook.php


<html>
<head><title>PHP workshop for form management: ajoutimp.php</title><head>
<body>
<?php






$continu=1;
if ($nom == "")
{
print("Your name is needed ");
$continu=0;
}

$db = mysql_connect($localhost,$spring85195,$)

if ($continu == 1)
{
$date=date("Y-m-d");
$sql="INSERT INTO impression (name, email, impression, date, comments) VALUES ('$name', '$email', 'impression', '$date', '$comments')";
mysql_query($sql, $db);
print("Thank you for giving me your impressions !") ;
}
else
{
print("<a href=impressions.html>back</a>");
}
?>
</body>
</html>






Here is the adminimp.php




<br><br><br><br><br><br><br><br><br><br><br> <html>
<head><title>PHP workshop for form management: adminimp.php</title><head>
<body>
<table align="center" cellspacing="0" cellpadding="0" border="1" width="80%">
<tr>
<td bgcolor="black"><font color="white">DATE</td>
<td bgcolor="black"><font color="white">NAME</td>
<td bgcolor="black"><font color="white">EMAIL</td>
<td bgcolor="black"><font color="white">IMPRESSION</td>
<td bgcolor="black"><font color="white">COMMENTS</td>
</tr>
<?php
$db = mysql_connect();
$sql="SELECT * FROM impression ORDER BY date";
$res=mysql_query($sql, $db);
while ($ligne = mysql_fetch_object ($res))
{
print "<tr>";
print "<td>$ligne->date</td>";
print "<td>$ligne->nom</td>";
print "<td>$ligne->email</td>";
print "<td>$ligne->impression</td>";
print "<td>$ligne->comments</td>";
print "</tr>";
}
mysql_free_result ($res);
?>
</table>
</body>
</html>







Many thanks to who will help me or tried to help me out.
User avatar
wmasterj
Forum Commoner
Posts: 40
Joined: Mon Aug 18, 2003 5:52 pm
Location: Stockholm, Sweden

Post by wmasterj »

no id mate????? :?: :?:
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Sorry no time to look at this in detail but http://www.hotscripts.com/PHP/Software_ ... tion_Kits/ might be some help (I'm guessing you don't have a local server).
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post by Cruzado_Mainfrm »

are you sure this is ok?

Code: Select all

<?php
$db = mysql_connect($localhost,$spring85195,$) 
?>
cuz there's that last $ sign that doesn't have any variable name at the end... it might not be the problem but that could cause other parsing errors...

and to use ID's you don't have to specify them in your query :D
ex.:

Code: Select all

the table:
id - name
0    john
1    rick
where id has auto_increment...
there query to insert another name will simply be:

Code: Select all

INSERT INTO table (name) VALUES ('daisy')
Post Reply