Solve this PHP problem

Status
Not open for further replies.

JhonCena

Journeyman
Plzzz solve this php problem:

Code:
<html>
<head>
<title>The Joke database</title>
</head>
<body>

<?php if (isses($_GET['addjoke'])):
?>

<form action="<?echo $_SERVER['PHP_SELF']; ?>" mehod='post'>
<label>Type your joke here:<br />
</textarea></label><br />
<input type="submit" value="SUBMIT" />
</forum>

<?php
else:$dbcnx = @mysql_connect('localhost', 'root', '********');
if (!dbcnx) {
exit('<p>Unable to connect to the ' .
'database server at this time.</p>');
}

if (!@mysql_select_db('ijdb')) {
exit('<p>Unable</p>');
}

if (isset($_POST['joke'])) {
$joke = $_POST['joke'];
$sql = "INSERT INTO joke SET
joke='$joke',
jokesate=CURDATE()";
if (mysql_query($sql)) {
echo '<p>Your joke has been added. </p>';
} else {
echo '<p>EROR adding submitted joke ' .
mysql_eror() . '</p>';
}

echo '<p>Here are all the jokes in our database.</p>';

$result = @mysql_query('SELECT joke FROM joke');
if (!result) {
exit('<p>Eror</p>');
}

while ($row = mysql_fetch_array($result)) {
echo '<p>' . $row['joke'] . '</p>';
}

echo '<p><a href="' . $_SERVER['PHP_SELF'] .
'?addjoke=1">Add a Joke!</a></p>';

endif;

?>

</body>
</html>



Error:

Code:
Parse error: parse error, unexpected T_ENDIF in C:\Program Files\VertrigoServ\www\tutorial\jokes.php on line 53


Solve this prob plzzz
 

Saharika

In the zone
any way looking at the code...it shows that you are new to php and trying to edit some script (i think i saw it in zend site)

about script bad news is that it may have suffered even bigger problem as i feel like you have not gone php toturials or books ...as you have not read about main function like isset...
(i am not saying it negatively)

so keep it up but rather than directly editing others codes first read the basics...may be good books ,toturials site...and then may be edit...

here main cause of error seem to be end if
so may be you can do like this

<html>
<head>
<title>The Joke database</title>
</head>
<body>

<?php if (isset($_GET['addjoke'])):
{
?>

<form action="<?echo $_SERVER['PHP_SELF']; ?>" mehod='post'>
<label>Type your joke here:<br />
</textarea></label><br />
<input type="submit" value="SUBMIT" />
</form>

<?php
}
else
$dbcnx = @mysql_connect('localhost', 'root', '********');

if (!dbcnx)
{
exit('<p>Unable to connect to the ' .'database server at this time.</p>');
}

if (!@mysql_select_db('ijdb'))
{
exit('<p>Unable</p>');
}

if (isset($_POST['joke']))
{
$joke = $_POST['joke'];
$sql = "INSERT INTO joke SET joke='$joke',jokesate=CURDATE()";

if (mysql_query($sql))
{
echo '<p>Your joke has been added. </p>';
}
else
{
echo '<p>EROR adding submitted joke ' .
mysql_eror() . '</p>';
}


echo '<p>Here are all the jokes in our database.</p>';

$result = @mysql_query('SELECT joke FROM joke');
if (!result)
{
exit('<p>Eror</p>');
}

while ($row = mysql_fetch_array($result))
{
echo '<p>' . $row['joke'] . '</p>';
}

echo '<p><a href="' . $_SERVER['PHP_SELF'] .'?addjoke=1">Add a Joke!</a></p>';



}//close of main if showing form
?>

</body>
</html>


i dont saw much logical things but saw just semantical things


and other bitter truth is you usually get good support for php things here may be try www.sitepoint.com/forums

and may be i have also written a joke script for foreign client ..if u seriously need it
www.jokes.bestcyberzone.com
not ad as this is not my site...means not owner

enjoy
 
OP
JhonCena

JhonCena

Journeyman
Now there is

Parse error: parse error, unexpected $end in C:\Program Files\VertrigoServ\www\tutorial\j2.php on line 69

I am very new to php and mysql and I got this from an ebook by kevin yank. tell me links of some more tutorials and free ebooks to learn php and mysql

Plzzz use code tags next time
 

Saharika

In the zone
JhonCena said:
Now there is

Parse error: parse error, unexpected $end in C:\Program Files\VertrigoServ\www\tutorial\j2.php on line 69

I am very new to php and mysql and I got this from an ebook by kevin yank. tell me links of some more tutorials and free ebooks to learn php and mysql

Plzzz use code tags next time
ya the problem seems to be with the config rather than syntax
you would be better to post it in forum like
sitepoint.com/forums

by the way it is almost like official forum for that yank book so u will get great support there
 

bpeel

Right off the assembly line
I think you forgot a } for the if statement from this piece of code:

if (isset($_POST['joke'])) {
$joke = $_POST['joke'];
$sql = "INSERT INTO joke SET joke='$joke', jokesate=CURDATE()";
if (mysql_query($sql)) {
echo '<p>Your joke has been added. </p>';
}
else
{
echo '<p>EROR adding submitted joke ' . mysql_eror() . '</p>';
}
 
OP
JhonCena

JhonCena

Journeyman
Thanks for the late reply

I think you are very new to this forum
hi and welcome to thinkdigit forum. and happy foruming. hope you ll like to stay here. read all the rules of thinkdigit forum before proceeding

next time use code tags ([CODE some code [/CODE)
thanx 4 reply I 'll try this later
 
Status
Not open for further replies.
Top Bottom