vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   How to fetch a userid (https://vborg.vbsupport.ru/showthread.php?t=224647)

Sprite- 10-05-2009 09:38 PM

How to fetch a userid
 
I am writing a script that uses vbulletin for usernames and userids.

Currently, I know I can use

$info = fetch_userinfo($userid);
$username=$info["username"];
echo $username;

to display a username for a userid.

My problem is going the other way around. Does anyone know how to display a userid for a username?

Any help would be appreciated. Thanks!

Edit: Also I am aware that I can do this with an sql query. I don't want to have to do that.

Lynne 10-05-2009 10:56 PM

Look up fetch_userid_from_username in the API

Bandit8007 10-11-2009 09:52 AM

hello people can somebody help out on a lillte issue i have?

im using a own build php script that does read a txt file and tranfers it intoo a sorted php file
but it was build for a blog....

to tell what it does in short is....

ya can manually add releases to page... sofar it works fine but i can't get the userinfo on it

Code:

                                global $user_identity;
                                get_currentuserinfo();

                               
                                $todaydate = date("m/d/Y");
                               
                                $riplist .= '{[1] = [[music]],[2] = [['.$user_identity.']],[3] = [['.$todaydate.']],[4] = [['.$artist.' ('.$year.') '.$album.']],},'."\r\n";
                       
                        }
                       
                        // append closing bracket to riplist.
                        $riplist = $riplist."}";
                       
                        // we have our riplist, now write to file.
                        if ($handle = fopen ($rel_file3, "ab")) {
                                // find the file size in bytes and remove one ie trailing bracket on last line
                                $truncate = filesize("$rel_file3") - 1;
                                // remove trailing bracket.
                                ftruncate ($handle, $truncate);
                                // write our new rips plus closing bracket }
                                if (fwrite($handle, $riplist)) {
                                        print "<p>Thanks! Your rips were successfully added to the database.</p>";
                                } else {
                                        print "<p>Something went wrong with the writing to DB file process. Please report to admin.</p>";
                                }
                                fclose($handle);
                        } else {
                                print "<p>Couldn't open the file for writing!</p>";
                        }
               
                } else
               
                        print "<p>You didn't not add owt.</p>";
       
        }

sofar that works fine
but i have trouble to add the user that posted it

Code:

                                global $user_identity;
                                get_currentuserinfo();

                               
                                $todaydate = date("m/d/Y");
                               
                                $riplist .= '{[1] = [[music]],[2] = [['.$user_identity.']],[3] = [['.$todaydate.']],[4] = [['.$artist.' ('.$year.') '.$album.']],},'."\r\n";
                       
                        }

the last coded part us the issue

cause im getting the error:

Fatal error: Call to undefined function fetch_userinfo() in /var/www/Forum/database/releases.php on line 324

line 324 is empty

322> global $user_identity;
323> get_currentuserinfo();
324> empty

any idea how to fix?
thnx :)

Lynne 10-11-2009 02:58 PM

This error:
PHP Code:

Call to undefined function fetch_userinfo() in /var/www/Forum/database/releases.php on line 324 

.... it can't find the function. Did you include the file that defines the function fetch_userinfo in your code?

Bandit8007 10-11-2009 04:53 PM

im sorry i mixed up the first soultion... that was posted in here

the fatal error that takes place is
Code:

Fatal error: Call to undefined function get_currentuserinfo() in /var/www/Forum/database/releases.php on line 323
and this is what script does use now ( but thats wordpress code)
Code:

322> global $user_identity;
323> get_currentuserinfo();
324> empty

so it wont work with vbulletin

so im trying to get a work around to get the userinfo....

Lynne 10-11-2009 05:40 PM

Weel again, it's an unidentified function which means you are calling it, but the file that contains the function is not being included. What file do you identify the function get_currentuserinfo in?

Bandit8007 10-12-2009 01:23 PM

well im not sure i understand fully...

but it does concern the current user thats on that(Vbulletin) page to post a release

to explain in short...

ive created a empty page as did get posted in here in mods
and used $include php for it

a part of that script is posted on post nr 9 above
anything does work fine on a wordpress instalation

but not on VB...

cause the member thats online on VB and that wants to post a release will not be added due that error it does gave...

so i need to change that script so it gets the user thats on VB and that does post that release....

maybe this helps you... ( i hope)..
if not then ill gave the full script ect what belongs to it... send me then a pm pls

gracias Lynne :)

Lynne 10-12-2009 01:46 PM

The problem is it wants to use the function get_currentuserinfo() but it is unable to since you haven't included the function in the script. Find the function in your files and either copy it into your page or include the page in your script:
PHP Code:

require_once(DIR '/thatPage.php'); 


Bandit8007 10-13-2009 04:26 AM

Lynne i think ya total misunderstand me a bit or i fail to explain it correctly...
but im gonnay try to explaim a bit easyer

in root >> new made empty page called releases.php if has indeed included the php that needs to be show >>
PHP Code:

<tbody>
<tr>


<td colspan="2"><p><?php      include('database/releases.php'); ?></p>

    </tr>
</tbody>
</table>

that /database/releases.php <<<

does look for that userinfo

ill post that part ofl script

from line 322 until 354

and the error i do get comes from that line 324
(again this worked in wordpress but not in vbulletin)
Code:

                                global $user_identity;
                                get_currentuserinfo();

                               
                                $todaydate = date("m/d/Y");
                               
                                $riplist .= '{[1] = [[music]],[2] = [['.$user_identity.']],[3] = [['.$todaydate.']],[4] = [['.$artist.' ('.$year.') '.$album.']],},'."\r\n";
                       
                        }
                       
                        // append closing bracket to riplist.
                        $riplist = $riplist."}";
                       
                        // we have our riplist, now write to file.
                        if ($handle = fopen ($rel_file3, "ab")) {
                                // find the file size in bytes and remove one ie trailing bracket on last line
                                $truncate = filesize("$rel_file3") - 1;
                                // remove trailing bracket.
                                ftruncate ($handle, $truncate);
                                // write our new rips plus closing bracket }
                                if (fwrite($handle, $riplist)) {
                                        print "<p>Thanks! Your rips were successfully added to the database.</p>";
                                } else {
                                        print "<p>Something went wrong with the writing to DB file process. Please report to admin.</p>";
                                }
                                fclose($handle);
                        } else {
                                print "<p>Couldn't open the file for writing!</p>";
                        }
               
                } else
               
                        print "<p>You didn't not add owt.</p>";
       
        }


Lynne 10-13-2009 01:33 PM

OK, let's start with this.... what file is the function get_currentuserinfo in? Is it in the releases.php file? Is that file readable to the public? Try copying the function out of the file and putting it into your page - does it work now?


All times are GMT. The time now is 04:06 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01598 seconds
  • Memory Usage 1,763KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete