![]() |
Query problem with username
Seems simple enough, but I have a way with making it difficult it seems. :(
I have a variable that is loaded, $username And I want to fill the variable $useremail from that username This will go in a php file. But I cant figure out how to do a query that will accomplish this. $username $useremail = sqlquery from the $username Can someone smak me with the obvious please? |
Here you go...
Code:
$tmpname = $vbulletin->db->query_first("SELECT email |
Thanks, giving it a try now.
Quick question?... can I do this to put it into an html template? Code:
<?php Reason asking about the html template is, I found where I need to inject this query is in an embedded html template within the php file. Code:
<?php "Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING" in WHERE username = '" . \$username . "'"); I have to add the backslashes infront of $ to eliminate another error. --------------- Added [DATE]1368135094[/DATE] at [TIME]1368135094[/TIME] --------------- $HTML_header_t is the only place I can execute this sql query, with of course $useremail being printed in the body of that page.. Code:
<?php |
You cannot put php into a template. You need to put the php into a plugin and then you preregister the resulting variable for the variable you are going to use it in. It's not clear at all which template you are wanting to use this in so there is no way I can get more specific.
I can point you to this article about preregistering variables (near the end) - [vB4] Rendering templates and registering variables - a short guide |
Quote:
I am reading that and hopefully may find a solution. This isnt a template per se', at least not a stock vb template. It is a custom file and called by another custom file. It is a php file as you can see at the bottom of my last post for part of it. Unless that is a template by definition. --------------- Added [DATE]1368150006[/DATE] at [TIME]1368150006[/TIME] --------------- Lynne, I read that completely and I do understand what I have read, but that doesnt, nor can it, apply here. I know that my problem is the sql syntax here, and I cant seem to find the syntax issue. Thanks anyway, but still looking for a tad bit-o-help. |
When you use HTML and PHP mixed on a page, you use the .php extension for the file but you separate the PHP and HTML like this...
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> So something like this would be needed... Code:
<?php |
If you include or requite global.php you should be able to get any user information without an extra query, something like this:
$vbulletin->userinfo['email'] |
If you include the global.php file, you don't need to also include the init.php file.
|
You should probably use $vbulletin->db->escape_string($username) in the query, otherwise if a username has a special character it may cause an error.
|
Quote:
|
All times are GMT. The time now is 05:38 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 | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|