PhotoPlog

PhotoPlog (http://www.photoplog.com/forum/index.php)
-   Miscellaneous Foobar (http://www.photoplog.com/forum/forumdisplay.php?f=4)
-   -   what sql statement do I use... (http://www.photoplog.com/forum/showthread.php?t=1313)

luker 06-20-2007 02:59 AM

what sql statement do I use...
 
In order to capture the userid on a non-vb page given the username?

Morgan 06-20-2007 05:23 AM

One possibility...
Code:

$user_name = 'foobar'; // set the vB user name
$table_prefix = 'vb3_'; // set your vB table prefix

$query_result = mysql_query("
        SELECT userid
        FROM " . $table_prefix . "user
        WHERE username = '" . mysql_real_escape_string(htmlspecialchars($user_name)) . "'
");


luker 06-20-2007 06:28 AM

thanks, I'm playing around with that.
heres what I used to find the userid
PHP Code:

//get the photoplog userid based on the vb username
$user_name '$Name'// $Name is the vb username

$name_query mysql_query("
    SELECT userid
    FROM photoplog_user
    WHERE username = '" 
mysql_real_escape_string(htmlspecialchars($user_name)) . "'
"
) or die(mysql_error());
$name_result mysql_fetch_array($name_query); 

then here is how I output it
PHP Code:

echo "<div style='float:right'><a href='/photoplog/gallery.php?".$name_result."'>>>more</a></div>"

http://lvasp.com/provider_page.php?ID=5

ragtek 06-20-2007 07:01 AM

are you sure thet you have the db ;)
are you sure that the data are in?

there are many things they can be

than is your code not right!
with this query you get an array back(if it works:D) but in your output you use a variable!

$name_result['userid'] shout it be

but i'm not sure if there are more errors


All times are GMT. The time now is 10:31 PM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.