/    Sign up×
Community /Pin to ProfileBookmark

hi,
i have make a login system in which when one logins he will be redirected to the menu page and from there he can ad and remove clubname and playerdetails, when clubname button is pressed add/delete buttons appear on the write side…..the problem is over here after pressing clubname button it gives an error(Parse error: syntax error, unexpected $end)…..please the kindly help me with it….thanks the code is given below….

[code=php]<?php
echo “<h3>$pagetitle</h3>”;
?>
<ul class=”ulnav”>
<li><a href=”index.php?page=category&action=addcategory”>Add New</a></li>
<li><a href=”index.php?page=category&action=editdelete”>Edit/Delete</a></li>
</ul>
<br>
<br>
<?php
if ($_REQUEST[‘page’] == ‘category’ && $_REQUEST[‘action’] == ‘addcategory’) {

if (isset($_REQUEST[‘submit’])) {

$category = $_REQUEST[‘category’];

if ($category != ”){

$chkcat = “select * from category where category=’$category'”;
$chkr = mysql_query($chkcat);
$chknr = mysql_num_rows($chkr);

if ($chknr>0) {
echo “<span class=’message’>Category already exists</span><br><br>”;
} else {
$insert = “insert into category (category) values (‘$category’)”;
mysql_query($insert);
echo “<span class=’message’>Category inserted successfully</span><br><br>”;
}
} else {
echo “<span class=’message’>The Category field must not be empty</span><br><br>”;
}

} else {

?>
<form action=”index.php?page=category&action=addcategory” method=”post” enctype=”multipart/form-data” class=”categoryform” onsubmit=”return validate_registration_form(this)”>
<table>
<tr><td style=”text-align:center;”><p>Please do not include any special characters like <strong>’ ” @ # $ % ^ & * ( ) _ + = -</strong> <br/ > Please use <strong>”and”</strong> instead of <strong>”&amp;”</strong></p></td></tr>
<tr><td style=”text-align:center;”>Category: <input type=”text” name=”category” /></td></tr>
<tr><td style=”text-align:center;”><input type=”submit” name=”submit” value=”Add” style=”color:#000066; text-decoration:none; font-size:100%; padding:5px 10px; margin:0 auto; border:1px solid #00CCFF; background:#DFEBFD;” /> <input type=”reset” name=”reset” value=”Clear form” style=”color:#000066; text-decoration:none; font-size:100%; padding:5px 10px; margin:0 auto; border:1px solid #00CCFF; background:#DFEBFD;” /></td></tr>
</table>
</form>
<?php
} // main form else ends here

} else if ($_REQUEST[‘action’] == ‘editdelete’) {

if (isset($_REQUEST[‘changecategory’]) && $_REQUEST[‘page’] == ‘category’) {
$id = $_REQUEST[‘id’];
$category = $_REQUEST[‘category’];

if ($category != ”)
{
$ucat = “update category set category=’$category’ where id=’$id'”;
mysql_query($ucat);
echo “Updated Successfully<br />”;
}

} else if (isset($_REQUEST[‘deletecategory’]) && $_REQUEST[‘page’] == ‘category’) {

$id = $_REQUEST[‘id’];

// fetch scategory for deleting process
$fscat = “select * from scategory where catid=’$id'”;
$fr = mysql_query($fscat);
$frnr = mysql_num_rows($fr);
if ($frnr > 0) {
for ($f=0; $f<$frnr; $f++)
{
$frw = mysql_fetch_array($fr);
$bdelete = “delete from books where scategory='”.$frw[‘scategory’].”‘”;
mysql_query($bdelete);
}
}

$fres = mysql_query($fscat);
$fresnr = mysql_num_rows($fres);
if ($fresnr > 0) {
$sdelete = “delete from scategory where catid=’$id'”;
mysql_query($sdelete);
}

$delete = “delete from category where id=’$id'”;
mysql_query($delete);

echo “<span class=’message’>Data deleted successfully.</span><br />”;
}

?>
<h4>Select the Category to edit</h4>
<?php
$gcat = “select * from category order by category”;
$gcatr = mysql_query($gcat) or die(“Error: ” . mysql_error());
$gcatnr = mysql_num_rows($gcatr);

if ($gcatnr>0) {
echo “<p>Please do not include any special characters like <strong>’ ” @ # $ % ^ & * ( ) _ + = -</strong> <br/ > Please use <strong>”and”</strong> instead of <strong>”&amp;”</strong></p>”;
for ($g=0; $g<$gcatnr; $g++)
{
$gcatrw = mysql_fetch_array($gcatr);
echo “<form action=’index.php?page=category&action=editdelete’ method=’post’ style=’margin:5px; padding:5px;’>”;
echo “<input type=’hidden’ name=’id’ value='”.$gcatrw[‘id’].”‘ />”;
echo “Category: <input type=’text’ name=’category’ value='”.$gcatrw[‘category’].”‘/>”;
echo “<br/><input type=’submit’ name=’changecategory’ value=’Change’ style=’color:#000066; text-decoration:none; font-size:100%; padding:5px 10px; margin:0 auto; border:1px solid #00CCFF; background:#DFEBFD;’ /> “;
echo “<input type=’submit’ name=’deletecategory’ value=’Delete’ style=’color:#000066; text-decoration:none; font-size:100%; padding:5px 10px; margin:0 auto; border:1px solid #00CCFF; background:#DFEBFD;’ onclick=’javascript: return confirm(“This action will delete all the data related to this category including subcategories and the books listed”);’/>”;
echo “</form><br />”;
}

} else {
echo “No results”;
}

?>
<?php
}
?>[/code]

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@mackilMar 18.2009 — (Parse error: syntax error, unexpected $end)[/QUOTE]

The sort of error message usually means you're missing a curly brace or something along those lines. Check the line number the error gives you and make sure you have everything where it should be.
Copy linkTweet thisAlerts:
@SyCoMar 18.2009 — If you always indent you nested curly brackets pairs you'll find these kinds of errors are easier to find.
Copy linkTweet thisAlerts:
@tariq_wajihaauthorMar 18.2009 — thank you my friend....the script is working now
Copy linkTweet thisAlerts:
@tariq_wajihaauthorMar 18.2009 — one more thing i want to ask that if i want that client after inserting the data just open the link and view the record category wise how can i do that??
Copy linkTweet thisAlerts:
@SyCoMar 19.2009 — Create a display file to use an id passed in with GET (or POST) to look up the info in a database. So after insert the user is given the link with the newly inserted ID to pass to your display file.
Copy linkTweet thisAlerts:
@tariq_wajihaauthorMar 21.2009 — well the client wants that the data which he is inserting in the database can only be viewed by him when he wants it to be displayed to some other person he will write a link and the data will be infront of him.....hwo can i do that??
×

Success!

Help @tariq_wajiha spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...