Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Closed Thread
Old 04-24-2009, 01:47 AM Users from database
Average Talker

Posts: 22
Name: john
Trades: 0
Hi, i have here a upload system + a dropdown list of users you can select from DB.

The issue i want to fix is for it to display everyone username except mine, is there a way to do this? Here is my script below and thankyou!

PHP Code:
<?php
if(isset($_SESSION['user']))
{
    
//Show content for users logged in

include 'connect.php';

$result mysql_query("SELECT * FROM members WHERE id != '" $myId "'");
print 
"<form action='process_upload.php' method='post' enctype='multipart/form-data'>\n";
print 
"<strong>Opponent</strong>:\n";
print 
"<select name =\"oppname\">\n";
while (
$row mysql_fetch_array($result)){
    
$oppname1 $row['setname'];
    print 
"<option value='$oppname1'>$oppname1\n</option>";
    }
print 
"</select><br />\n";


?>
<br>

<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<label for="file"><strong>Replay</strong>:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="Upload" value="Submit" />
<br><br>
</form>
<?php } else  {
 echo 
"You are not allowed to do this, Please login or <u><a href='register.php'>register</a></u> an TGL account.";
?>
<?php
}
?>
microsoftx is offline
View Public Profile
 
 
Register now for full access!
Old 04-24-2009, 07:56 AM Re: Users from database
nayes84's Avatar
Extreme Talker

Latest Blog Post:
Difference between ASP And JSP
Posts: 232
Name: John
Location: Tokyo
Trades: 0
you have a mistake in the sql query

Code:
SELECT * FROM members WHERE id <>'" . $myId . "'"
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

if(I'm("Helpful")) Add_Talkupation("nayes84");
nayes84 is offline
View Public Profile
 
Old 04-24-2009, 09:23 AM Re: Users from database
Average Talker

Posts: 22
Name: john
Trades: 0
Still not working it still displays my username on the dropdown list

PHP Code:
$result mysql_query("SELECT * FROM members WHERE id <>'" $myId "'");
print 
"<form action='process_upload.php' method='post' enctype='multipart/form-data'>\n";
print 
"<strong>Opponent</strong>:\n";
print 
"<select name =\"oppname\">\n";
while (
$row mysql_fetch_array($result)){
    
$oppname1 $row['setname'];
    print 
"<option value='$oppname1'>$oppname1\n</option>";
    }
print 
"</select><br />\n"
microsoftx is offline
View Public Profile
 
Old 04-24-2009, 09:28 AM Re: Users from database
GeorgeB's Avatar
I Love Lamp

Posts: 1,000
Trades: 0
PHP Code:
$result mysql_query("SELECT * FROM members WHERE id != '$myId'"); 
__________________
One of my biggest passions is
Please login or register to view this content. Registration is FREE
. I enjoy
Please login or register to view this content. Registration is FREE
and in my spare time hang out on
Please login or register to view this content. Registration is FREE
. I'm pretty well rounded. :)
GeorgeB is offline
View Public Profile Visit GeorgeB's homepage!
 
Old 11-24-2009, 09:23 AM Re: Users from database
Experienced Talker

Posts: 48
Name: Pieter
Location: Holland
Trades: 0
You didn't declare the $myid variable
it is just empty in this script, or do you get the infor from you're include?
elcosmo is offline
View Public Profile
 
Old 11-24-2009, 09:32 AM Re: Users from database
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
If the id column is numeric it should not have quotes surrounding it
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
View Public Profile Visit chrishirst's homepage!
 
Old 11-24-2009, 11:29 AM Re: Users from database
Super Talker

Posts: 139
Name: John Davis
Trades: 0
Quote:
Originally Posted by nayes84 View Post
you have a mistake in the sql query

Code:
SELECT * FROM members WHERE id <>'" . $myId . "'"
Mysql allows to use != same as <>
__________________
»
Please login or register to view this content. Registration is FREE
- Interactive maps for websites
»
Please login or register to view this content. Registration is FREE
for web developers
MapMaster is offline
View Public Profile Visit MapMaster's homepage!
 
Old 11-24-2009, 11:34 AM Re: Users from database
Super Talker

Posts: 139
Name: John Davis
Trades: 0
microsoftx, where from $myId comes?
__________________
»
Please login or register to view this content. Registration is FREE
- Interactive maps for websites
»
Please login or register to view this content. Registration is FREE
for web developers
MapMaster is offline
View Public Profile Visit MapMaster's homepage!
 
Old 11-24-2009, 11:37 AM Re: Users from database
Super Talker

Posts: 139
Name: John Davis
Trades: 0
Quote:
Originally Posted by chrishirst View Post
If the id column is numeric it should not have quotes surrounding it
quotes is not reason of query falling. But you right, numeric column may be user without quote.
__________________
»
Please login or register to view this content. Registration is FREE
- Interactive maps for websites
»
Please login or register to view this content. Registration is FREE
for web developers
MapMaster is offline
View Public Profile Visit MapMaster's homepage!
 
Old 11-26-2009, 04:32 PM Re: Users from database
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
I know it may be a bit cowboy ish.. However dont you just know your user id?

and instead of being all dynamic n all. Just do
select * from users where id != xx

?
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
View Public Profile Visit lynxus's homepage!
 
Old 11-27-2009, 07:13 AM Re: Users from database
Super Talker

Posts: 139
Name: John Davis
Trades: 0
lynxus, you wrote same query like microsoftx did
__________________
»
Please login or register to view this content. Registration is FREE
- Interactive maps for websites
»
Please login or register to view this content. Registration is FREE
for web developers
MapMaster is offline
View Public Profile Visit MapMaster's homepage!
 
Closed Thread     « Reply to Users from database
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.32244 seconds with 12 queries