Current location: Hot Scripts Forums » Programming Languages » PHP » Mysql Select IB FORUM PROBLEM


Mysql Select IB FORUM PROBLEM

Reply
  #1 (permalink)  
Old 07-23-04, 07:32 PM
landboy landboy is offline
Newbie Coder
 
Join Date: May 2004
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Mysql Select IB FORUM PROBLEM

Hello,
When i use this code to try to get all info from an ib forum member field it doesn't work.
I need it to check to make sure the user has 5 or more posts and exculty has an account

In IB i need to add "s around the name
SELECT * FROM ibf_members WHERE name="MyNameHere"
that works (in the ib toolbox) but It doesn't work in the script.

PHP Code:

$connect mysql_connect(localhost,forummaste_forum,forum) or die(mysql_error());

$db mysql_select_db(forummaste_forum,$connect) or die(mysql_error());

$select "SELECT * FROM ibf_members WHERE name="$ForumUser";
$query = mysql_query($select) or die(mysql_error());
$num = mysql_num_rows($query);

if (!
$num = 1) {
    print "
Error Forum Username Doesn't Excist";
    exit;

Please Help
Reply With Quote
  #2 (permalink)  
Old 07-23-04, 08:24 PM
kvnband kvnband is offline
Wannabe Coder
 
Join Date: Jun 2003
Posts: 242
Thanks: 0
Thanked 0 Times in 0 Posts
I'm no pro, but shouldn't

PHP Code:

if (!$num 1
be
PHP Code:

if($num != 1
?

I'm pretty sure that it should be.
Reply With Quote
  #3 (permalink)  
Old 07-23-04, 08:27 PM
kvnband kvnband is offline
Wannabe Coder
 
Join Date: Jun 2003
Posts: 242
Thanks: 0
Thanked 0 Times in 0 Posts
OH, and when defining the variable in the SQL query, it should be (I think)

PHP Code:

$select "SELECT * FROM ibf_members WHERE name=$ForumUser"
or
PHP Code:

$select "SELECT * FROM ibf_members WHERE name='ForumUser'"
If you want to have " inside of ", you have to escape them with a backslash

PHP Code:

echo "Hello what's up?  \"Get away from me!\""
Hope I haven't confused you, because I think I confused myself

Try that and get back to us. OH, and please let us know what errors you are getting (if any)

Kevin

Last edited by kvnband; 07-23-04 at 08:31 PM.
Reply With Quote
  #4 (permalink)  
Old 07-28-04, 10:33 AM
landboy landboy is offline
Newbie Coder
 
Join Date: May 2004
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
What i need to do is add "s (double quotes) around the variable $ForumUser so the vaule is
"Blah" insted of just Blah is there a function or a way to accomplishing this without having to go deep into coding.
Thanks,
Reply With Quote
  #5 (permalink)  
Old 07-28-04, 11:07 AM
infinitylimit's Avatar
infinitylimit infinitylimit is offline
Code Guru
 
Join Date: Jun 2004
Location: Oregon
Posts: 758
Thanks: 0
Thanked 0 Times in 0 Posts
Not that kevin gave you bad information but there is just a quicker more effecient way to do this.

PHP Code:

$select "SELECT * FROM ibf_members WHERE name=".$ForumUser

// should be

$select 'SELECT name FROM ib_members WHERE name="'.$ForumUser.'"'
Unless your going to be using $num later you also don't need to assigned a variable.

Also you might want to take your uid and pwd our of the mysql_connect.
__________________
Hawk Enterprises -- Home to PHP games, open-source code, tutorials and free downloads
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
Database table contents to email problem (PHP and MySQL) blokeofftheinternet PHP 2 04-29-04 09:34 AM
Load Data Infile Problem (MySQL) Shaky2 PHP 1 03-26-04 04:48 PM
MySQL Expert Required!! Advanced Query Problem bluey_the_punch PHP 1 02-28-04 01:37 PM
MYSQL problem pk_jsp PHP 1 12-13-03 04:22 PM


All times are GMT -5. The time now is 04:13 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.