Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-08-2007, 12:08 PM
CP, CP, is offline
 
Join Date: Aug 2005
Location: UK London
Posts: 276
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default calling all php and mysql guru's

Ive been searching for a day now and im going to cry soon.

I am to make a project a dummy website e-commerce website. So security and all the other things are not so important, just need things to be bland and plain but most importantly to work!

Ive got a mysql db set up, and my users can log in and log out thats working.

Now here is the problem. Once that particular user logs in i want him/her to be able to view the details stored on the db about them, i.e. their firstname, surname, email etc

Ive been trying so many methods but none seem to work or some are giving me blank results. If somebody can help me with this, it would be much appreciated.
Reply With Quote
  #2  
Old 04-09-2007, 06:16 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is this using your own backend or vBulletin's? (I'm guessing your own) You will need to query the database for the user's row and output the information.
PHP Code:
$result mysql_query("SELECT * FROM `YOURUSERTABLE` WHERE `userid` = " $YOURUSERIDVARIABLE " LIMIT 1");
$row mysql_fetch_assoc($result); 
Then all your information would be in $row. To access it's data, simply use $row['FIELD'] (where FIELD is the name of the required field).
Reply With Quote
  #3  
Old 04-09-2007, 06:28 PM
CP, CP, is offline
 
Join Date: Aug 2005
Location: UK London
Posts: 276
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is the test data in my contacts table as you can see: http://www.photo-host.org/img/958319table.jpg

ive inserted this, is this correct?:

Code:
$result = mysql_query("SELECT * FROM 'contacts' WHERE 'member_id' = " . $member_id . " LIMIT 1");
$row = mysql_fetch_assoc($result);
contacts is the table and member_id is the member id which auto increments as a new user registers.

I can login in fine with this error on top:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in e:\webareas\am663\carttest\login.php on line 8

EDIT: I added the "@" in front of mysql_fetch_assoc($result); which seemed to have removed the error message but when i call the data from the db e.g. echo $row['$member_id'];
echo $row['$username'];
nothing shows up on my members page?
Reply With Quote
  #4  
Old 04-09-2007, 07:22 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
$result mysql_query("
    SELECT * 
    FROM contacts 
    WHERE member_id = 
$member_id 
"
) or die(mysql_error());
$row mysql_fetch_assoc($result); 
Reply With Quote
  #5  
Old 04-09-2007, 08:10 PM
CP, CP, is offline
 
Join Date: Aug 2005
Location: UK London
Posts: 276
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by SirAdrian View Post
$result = mysql_query("
SELECT *
FROM contacts
WHERE member_id = $member_id
") or die(mysql_erorr());
$row = mysql_fetch_assoc($result);[/code]
you have a typo i quickly fixed it, is it suppose to be in 6 lines? as i reduce it to 1 line the colour changes... but i still followed your example and it said:

"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3" ?? Im on my university server, do i upload a phpinfo file to find out?
Reply With Quote
  #6  
Old 04-09-2007, 08:25 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What is the $member_id value set to? I'm assuming it's an integer... right?
Reply With Quote
  #7  
Old 04-09-2007, 08:31 PM
CP, CP, is offline
 
Join Date: Aug 2005
Location: UK London
Posts: 276
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by SirAdrian View Post
What is the $member_id value set to? I'm assuming it's an integer... right?
look here: http://www.photo-host.org/img/958319table.jpg member id is an auto increment integer.

Code:
CREATE TABLE contacts (
  member_id int(30) NOT NULL auto_increment,
  firstname varchar(30) NOT NULL default '',
  surname VARCHAR(30) NOT NULL default '',
  contact_no INT(11),
  housename_no VARCHAR(20),
  address_line1 VARCHAR(20),
  address_line2 VARCHAR(20),
  address_line3 VARCHAR(20),
  city_county VARCHAR(15),
  postcode VARCHAR(8),
  email varchar(30) NOT NULL default '',
  username varchar(25) NOT NULL default '',
  password varchar(255) NOT NULL default '',
  PRIMARY KEY  (member_id),
  UNIQUE KEY username (username)
) TYPE=MyISAM COMMENT='Members';
Reply With Quote
  #8  
Old 04-09-2007, 09:15 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In your query you use $member_id ... what is the value of that?
Reply With Quote
  #9  
Old 04-09-2007, 09:28 PM
CP, CP, is offline
 
Join Date: Aug 2005
Location: UK London
Posts: 276
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by SirAdrian View Post
In your query you use $member_id ... what is the value of that?
What do you mean? the value in the sql table or in the php code?
Reply With Quote
  #10  
Old 04-09-2007, 09:31 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The PHP variable... if its empty (and I'm pretty sure it is) the query will die because:

SELECT * FROM TABLE WHERE id = ;

Is not valid.
Reply With Quote
Reply


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

Forum Jump


All times are GMT. The time now is 09:28 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07010 seconds
  • Memory Usage 2,261KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (2)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete