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

Reply
 
Thread Tools Display Modes
  #11  
Old 05-11-2013, 10:45 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You would just insert it where you use $username in the query. For example in the code nhawk posted it would be:

Code:
$tmpname = $vbulletin->db->query_first("SELECT email 
FROM " . TABLE_PREFIX . "user 
WHERE username = '" . $vbulletin->db->escape_string($username) . "'");

$useremail = $tmpname['email'];
Reply With Quote
  #12  
Old 05-14-2013, 02:48 AM
smirkley smirkley is offline
 
Join Date: Apr 2008
Posts: 627
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have attempted and tried every which way to make any of you all's suggestions, to my dismay unsuccessfully.

It seems something in the query string that is outputting a syntax error and it will not perform the query.

"Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING"

Now, I know that there can be some sql differences in revision, I am currently running on "mySQL rev: 5.0.96-community-log".

I know on another site I had to make some changes after performing an sql upgrade in rev, but I cant see here where my problem might be here.
Reply With Quote
  #13  
Old 05-14-2013, 10:07 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Looks like a typo or mismatched quotes or something like that. You'd have to post your exact code.
Reply With Quote
  #14  
Old 05-14-2013, 01:42 PM
smirkley smirkley is offline
 
Join Date: Apr 2008
Posts: 627
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
You would just insert it where you use $username in the query. For example in the code nhawk posted it would be:

Code:
$tmpname = $vbulletin->db->query_first("SELECT email 
FROM " . TABLE_PREFIX . "user 
WHERE username = '" . $vbulletin->db->escape_string($username) . "'");

$useremail = $tmpname['email'];
Well, the code you suggested.
I know I have to add a preceeding backslash to all points of $, and that doesnt change execution but on my setup adding the backslash removes the initial error.

But now it hangs on :

$tmpname = $vbulletin->db->query_first("SELECT email
FROM " . TABLE_PREFIX . "user
WHERE username = '" . $vbulletin->db->escape_string($username) . "'");
Reply With Quote
  #15  
Old 05-14-2013, 01:48 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm, well, it's true that I haven't tried any of that code, but it looks OK. You shouldn't have to add any backslashes to it if you have the quotes right, because the $vbulletin->db->escape_string($username) part isn't inside the quotes.

Maybe someone else will see something I missed.
Reply With Quote
  #16  
Old 05-16-2013, 06:50 PM
DaveNGU DaveNGU is offline
 
Join Date: Mar 2012
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you say this is in a custom file? If it is, there's no need to use $vbulletin->db->query_first - just use PHP.

But, assuming its not (in all honesty I haven't read all of this), try this..

Code:
$tmpname = $vbulletin->db->query_first("
SELECT email 
FROM " . TABLE_PREFIX . "user 
WHERE username = '" . $vbulletin->db->escape_string($username) . "'
");

$tmpnamer = $tmpname->row_array(); 

$usermail = $tmpnamer['email'];

echo $usermail;
Reply With Quote
  #17  
Old 05-16-2013, 07:32 PM
tbworld tbworld is offline
 
Join Date: Oct 2008
Posts: 2,126
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Reading this I believe you need to post your code. Are you querying for the current username, a selected username or creating a list for their email.

If I am reading in between the lines correctly, I think you have been trying to embed the query inside the escaped html string <-- you are calling an embedded template.

What we need to do is restructure what you have so you can see your way clear.
Reply With Quote
  #18  
Old 05-17-2013, 03:51 AM
smirkley smirkley is offline
 
Join Date: Apr 2008
Posts: 627
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by tbworld View Post
Reading this I believe you need to post your code. Are you querying for the current username, a selected username or creating a list for their email.

If I am reading in between the lines correctly, I think you have been trying to embed the query inside the escaped html string <-- you are calling an embedded template.

What we need to do is restructure what you have so you can see your way clear.
I think I will have to post a portion of the code. I dont know that I have rights to post it completely though, as it is propietary.

IE:

I run a third party product on my vb that uses a php based template, albiet that it is mixed with php and template html.

And it works, and by generating a page consisting of a header/body/footer.

In this template are variables like $username and a few others. $username is populated in the php file that calles this "template".php. And $username can and is used in the html part of the file.

I have a need now to create a way of making $useremail work the same way.



But the snag, or I would have it by now myself, the file that fills $username is encoded so that file can not be changed.

My only option is to find a way to make it work by way of a query, in the template file as it isnt encoded.

Otherwise I am SOL.
Reply With Quote
  #19  
Old 05-17-2013, 04:41 AM
tbworld tbworld is offline
 
Join Date: Oct 2008
Posts: 2,126
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
But the snag, or I would have it by now myself, the file that fills $username is encoded so that file can not be changed.
Is this a vbulletin page calling a vbulletin template or an external page calling their own type of mixed php/html template?

Is the outputting of the template encoded? (Not the template)
Can you parse the output $username in php to extract the data you need for your query?

Trying to understand a little further. Not all the questions I asked above will make sense
under your code condition, but it will let me fill in the gaps of information.
Reply With Quote
  #20  
Old 05-17-2013, 01:01 PM
smirkley smirkley is offline
 
Join Date: Apr 2008
Posts: 627
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It is not a vb page nor template, the php files although running as a vb product modification, run independantly from vb short of the attachment to the database and other misc variables.

The page generated does not contain vb elements such as vb header or footer, and the body is independant and stand-alone.

The output is not encoded, just the original process in the php files are. As a anote, I can unencode the calling file, but only to view its contents, I cannot run it outside of being encoded.

Yes the $username can and is parsed in the outputting of the html generated page reletive to the user that the page is generated for.
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 05:37 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.04026 seconds
  • Memory Usage 2,257KB
  • Queries Executed 13 (?)
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
  • (3)bbcode_code
  • (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
  • (2)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_postinfo_query
  • fetch_postinfo
  • 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