Search
Left Quote    I think there is a world market for maybe five computers.
- Thomas Watson, Chairman of IBM 1943    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: SQL Question
  This user is offline  gravy
  Subject: "SQL Question" Posted: @ 9:43 pm on Mar 11 2007   

Member #: 294
Rank: User - (63)
Since: 03/07/07
Posts: 66
From: MN

I get this error when I run this:

Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result resource in

Code:

<script language=" php"> if($react == "delete_us er" {
if($user) {
$query = "DELETE username user_id user_email user_password FROM members WHERE user_id = '$user'";< br /> $result = mysql_query($qu ery, $connection); if(mysql_num_ro ws($result)) {
print("< ;strong>$use r</strong> ; successfully deleted<p> ;";
}
} else {
print("< ;strong>No users are available to delete yet, sorry.</stro ng><p> ";
}
}
else {
print("< ;center>< /center>&quo t;
}
</script>
<form method="PO ST" action="ad min.php"&g t;<div align="cen ter">&l t;font size="2&qu ot; face="verd ana">&l t;center>< ;p>Delete Users
<input type="hidd en" name="reac t" value="del ete_user"& gt;
<select name="user " size="1&qu ot;>
<script language=" php"> $query = "SELECT username FROM members ORDER BY user_id";< br /> $result = mysql_query($qu ery, $connection); if(mysql_num_ro ws($result)) {
// we have at least one user, so show all users as options in select form
while($row = mysql_fetch_row ($result))
{
print("< ;option value=\"$r ow[0]\"> ;$row[0]</op tion>";
}
} else {
print("< ;option value=\"\& quot;>No users created yet</option& gt;";
}
</script>
</select> &nbsp; <input type="subm it" value="Del ete User"> </p>
</form>



I can get the members currently inside the members table to show in the drop down, but as soon as I press the delete button, I get the error above. I have racked my brain over this almost all day..


Photo Hosting Scripts? It's what I do....
    Viewed: 13,220 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: SQL Question" Posted: @ 10:19 pm on Mar 11 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

What do you mean by if($user) ? Maybe, if(!empty($user )) ? Also, on your delete query, I would do it like this:


Code:


$query = mysql_query(&q uot;DELETE FROM `members` WHERE `user_id` = '".$user ."'&quo t;
if(!$query) {
echo("use r not deleted."< img src=http://www. allsyntax.com/f orums/images/sm ilies/wink.gif border=0>;
} else {
echo("Use r deleted."< img src=http://www. allsyntax.com/f orums/images/sm ilies/wink.gif border=0>;
}


Also, to open PHP, I havent seen <script language=" ;php"> too much. You can just use <? or <?php if alot faster than typing all of that out.



Edited at 12:00:27 am on 03/12/07


-bs0d | AllSyntax.com

    Viewed: 13,212 Times | Reply to This | To top
  This user is offline  gravy
  Subject: "re: SQL Question" Posted: @ 12:38 am on Mar 12 2007    

Member #: 294
Rank: User - (63)
Since: 03/07/07
Posts: 66
From: MN

  bs0d said...

< i> What do you mean by if($user) ? Maybe, if(!empty($user )) ? Also, on your delete query, I would do it like this:

<BR><s pan style=font-size :10px;><u >Code:</u ></span&g t;<BR>< ;div name="div _box" class="di vCode"> ;
$query = mysql_query(&q uot;DELETE FROM `members` WHERE `user_id` = '".$user ."'&quo t;
if(!$query) {
echo("use r not deleted."< img src=http://www. allsyntax.com/f orums/images/sm ilies/wink.gif border=0>;
} else {
echo("Use r deleted."< img src=http://www. allsyntax.com/f orums/images/sm ilies/wink.gif border=0>;
}


Also, to open PHP, I havent seen <script language=" ;php"> too much. You can just use <? or <?php if alot faster than typing all of that out.

I went with a whole different method of selecting the user for deletion, and I am now close to getting done. It works now, I dont know what I did, must have changed something to the right whatever.

Yeah my editor opens that style of php for beginning and end. i change it to <? and ?> if I remember to




Photo Hosting Scripts? It's what I do....

    Viewed: 13,208 Times | Reply to This | To top
  This user is offline  gravy
  Subject: "re: SQL Question" Posted: @ 12:41 am on Mar 12 2007    

Member #: 294
Rank: User - (63)
Since: 03/07/07
Posts: 66
From: MN

basically what I am doing is making an admin section for your member registration script. so far I have each member's username, email, and ID to show on the page.

then you have the option to delete any member with the click of link.




Photo Hosting Scripts? It's what I do....

    Viewed: 13,206 Times | Reply to This | To top
  This user is offline  lingh0e
  Subject: "re: SQL Question" Posted: @ 5:34 am on Mar 13 2007    

Member #: 291
Rank: User - (29)
Since: 03/03/07
Posts: 29
From: Ohio

I'd be interested in this mod, since all the work I have been doing on my own site has been with the idea of eventually integrating it into a fully functional administrative panel...

Let me know how you progress. I'd be willing to help you work on it if you like.




Feel free to kick me if I get annoying

    Viewed: 13,175 Times | Reply to This | To top
  This user is offline  gravy
  Subject: "re: SQL Question" Posted: @ 11:53 pm on Mar 13 2007    

Member #: 294
Rank: User - (63)
Since: 03/07/07
Posts: 66
From: MN

  lingh0e said...

< i> I'd be interested in this mod, since all the work I have been doing on my own site has been with the idea of eventually integrating it into a fully functional administrative panel...

Let me know how you progress. I'd be willing to help you work on it if you like.


Hey man,
I have it now so that I can view and email, and delete any member, plus view and delete any comments, and view and delete any photos that are uploaded.

I can send you the code or part of it if you want it.




Photo Hosting Scripts? It's what I do....

    Viewed: 13,155 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: SQL Question" Posted: @ 1:36 am on Mar 14 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Hey, that view and delete uploaded photo's is a good idea... Hrm...




-bs0d | AllSyntax.com

    Viewed: 13,152 Times | Reply to This | To top
  This user is offline  gravy
  Subject: "re: SQL Question" Posted: @ 1:55 am on Mar 14 2007    

Member #: 294
Rank: User - (63)
Since: 03/07/07
Posts: 66
From: MN

LOL, yeah this is the first time I have incorperated these functions into my photo host script. Seems like a good idea to have these things available to the owner.




Photo Hosting Scripts? It's what I do....

    Viewed: 13,148 Times | Reply to This | To top
  This user is offline  gravy
  Subject: "re: SQL Question" Posted: @ 4:42 pm on Mar 14 2007    

Member #: 294
Rank: User - (63)
Since: 03/07/07
Posts: 66
From: MN

here is a screenshot of the admin:

Click Here



Edited at 04:43:46 pm on 03/14/07


Photo Hosting Scripts? It's what I do....

    Viewed: 13,125 Times | Reply to This | To top
  This user is offline  gravy
  Subject: "re: SQL Question" Posted: @ 7:04 pm on Mar 14 2007    

Member #: 294
Rank: User - (63)
Since: 03/07/07
Posts: 66
From: MN

Now I have another question.
How would be the best way to keep track of member uploaded images. So when they log in they can choose to see the photos they have uploaded?

I have tryed a few different ways but keep coming up with errors...

Anyone?




Photo Hosting Scripts? It's what I do....

    Viewed: 13,118 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: SQL Question" Posted: @ 10:11 pm on Mar 14 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

I think a simple way of doing it would be to name the images by username+whatev er. So display all images where the beginning of the image name is equal to the username




-bs0d | AllSyntax.com

    Viewed: 13,106 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank