i can't belive i can't get this...

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
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

i can't belive i can't get this...

Post by m3mn0n »

...;)

What i am doing is displaying a list of admins from a database:

Code: Select all

<?
mysql_connect("localhost","","");
mysql_select_db("");
$a=mysql_query("select * from members order by id");

echo "<table width=30% bgcolor=#EFEFEF align=center border=1 bordercolor=black>\n";
while($admin=mysql_fetch_array($a)){
echo "<tr align=center>\n";
echo "<td align=left><font size=1><strong>ID</strong>";
echo "<td align=left><font size=1><strong>Name</strong>";
echo "<td align=left><font size=1><strong>Username</strong>";
echo "<td align=left><font size=1><strong>Email</strong>";
echo "<td align=left><font size=1><strong>Delete?</strong>";
echo "</tr>";
echo "<tr align=center>\n";
echo "<td align=left><font size=1><br>$adminїid]";
echo "<td align=left><font size=1><br>$adminїname]";
echo "<td align=left><font size=1><br>$adminїlogin]";
echo "<td align=left><font size=1><br><a href=mailto:$adminїemail]>$adminїemail]</a>";
echo "<td align=left><font size=1>
<form action=administration.php method=post>
<input type=hidden value=$adminїid]>
<input name=Delete type=submit value=Delete>
</form>";
}
?>
Above, in the last tabledata tag i have tried to add in a delete query right into my page so i don't have to goto phpMyAdmin when i want to delete another admin. I am not sure that is the proper formation for it so if i got it wrong can anyone correct me?

Back to the main problem..

Code: Select all

<?
if ($Delete) {
$db=mysql_connect("localhost","") or die ("cant connect"); 
mysql_select_db("",$db) or die ("cant change");
$result=mysql_query("delete from members where id='$adminїid]'") or die ("</tr></table><br><br>Deletion <b>NOT</b> Successful!");
while ($row=mysql_fetch_array($result)) {
if ($rowї"id"]==""]) {
printf("</tr></table><br><br>Successfully Deleted!");
}
}
}

?>
for this line:

Code: Select all

if ($rowї"id"]==""]) {
where it says "id", i have tried every variable i could think of and even in the blank variable beside it, i tried all sorts of combinations, yet no luck.

Currently all the page displays is this:
Parse error: parse error in C:\apache\htdocs\x\x\x.php on line 46
46 is that line i highlighted btw...

can anyone help me out here?
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

Im no php expert but the small php error page i've made will tell you probably why... heres the snippet from the site....

Parse Errors.
1. Missing semicolon ";"
2. Missing dollar signs "$"
3. Missing curly brackets "{"
4. Missing parentheses "("
5. Quotes are not escaped ""
6. Missing include or required files.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

I know what the parse error is, just didnt bother to remove it ;)


The issue is the proper syntax to show IF the user was delete, display a deletion message. I have everything but that one bit of code to make it all work in sequence.
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

dont do an IF statement at all, if it failed deleting you used the die() statement, so if the user wasn't deleted it would die... thus you can assume it would load the code at the bottom if it was successful

Code: Select all

if($something == "failed"){
die("DIE!");
} 
echo "this is successful otherwise the script would have died, ya know?";
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

*slaps forehead*

thanks, ill see if that works.
Post Reply