vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   Which is the better code to use? (https://vborg.vbsupport.ru/showthread.php?t=52299)

Boofo 04-28-2003 09:16 PM

Which is the better code to use?
 
Can anyone pleases tell me which one of theses pieces of code is actually better to use in the register.php?

$getuser=$DB_site->query_first("SELECT username FROM user WHERE username='".addslashes($username)."'");

or

$getuser=$DB_site->query_first("SELECT username FROM user WHERE username='".addslashes(htmlspecialchars($username) )."'");

DigitalDesktops 04-28-2003 09:30 PM

the second one i believe :)

filburt1 04-28-2003 09:32 PM

If usernames are already htmlspecialchar'ed in the database, then the second one.

Boofo 04-28-2003 09:40 PM

Quote:

Today at 05:32 PM filburt1 said this in Post #3
If usernames are already htmlspecialchar'ed in the database, then the second one.
Ok, how would I find out if they are?

filburt1 04-28-2003 09:42 PM

Register at your own forums using a username with a > in it, and then run these query:
[sql]
SELECT username FROM user WHERE username LIKE "%>%";
SELECT username FROM user WHERE username LIKE "%>%";
[/sql]

edit: of course vB is parsing the entities...

Boofo 04-28-2003 09:52 PM

Here's the db error I got that is the basis for this question.

Database error in vBulletin 2.2.9:

Invalid SQL: SELECT username FROM user WHERE username='Julie'34'
mysql error: You have an error in your SQL syntax near '34'' at line 1

mysql error number: 1064

Date: Monday 28th of April 2003 02:03:42 PM
Script: http://www.bearfacts2.com/forum/forum/register.php
Referer: http://www.bearfacts2.com/forum/regi...p?action=check


All times are GMT. The time now is 10:28 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.01214 seconds
  • Memory Usage 1,719KB
  • 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
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete