which one is the best?
Started on the old forum in October 2012 · view the original in the archive · old links redirect here
jaidon20k wrote: Out of these sql statement which one is the best?
(1) $sql = "INSERT INTO members(id,firstn) VALUES('".$id."','".$fname."')";
(2) $sql = "INSERT INTO members SET id = '".$id."', firstn = '"..$fname."';
$sql = "INSERT INTO members (id,firstn) VALUES('".$id."','". $fname."')"; its better ,bt injectment are open
$XTREME$ wrote: $sql = "INSERT INTO members (id,firstn) VALUES('".$id."','". $fname."')"; its better ,bt injectment are open
<?php $sql = "INSERT INTO members(id,firstn) VALUES('".intval($id)."','".mysql_real_escape_string($fname)."')"; ?>This would be the best way :)
Like i said, there is no the best way between this two queries as they are for different purpose. And security nor escaping is in the question. 🙂 But when you mentioned, intval() should not be used here and it returns floats also where $id can't be float plus on invalid sets 0. And its quoted wrong. 😉
Read this http://coding-talk.com/f60/protecting-your-users-session-url-session-vars-%24_session-%24_cookie-17514/ and list Tutorials forum a little. 🙂
Edyka wrote: arnage.... there are only 2 statements... no 3rd :lol
Yes, it have. 😉
Not in the original post 🙂 the one by you can be ignored... that is just an example 😀 why not? intval returns only ints as I know? .... PS your PHP knowledge is great, but your english could use some training 🙂 PHP: intval - Manual returns only integers .. 🙂 and the best thing is the most seruced one 🙂 I bet the guy who opened the theme meant to ask for the more secure one 🙂
No. Floats, hex, minus values also. Read, read, read... PHP: intval - Manual ... and posted link before.
And please, stay on topic, no one cares about my or anyones english nor personality. That attitude leave at Serbian forums. 😉
Edyka wrote: PHP: intval - Manual returns only integers .. 🙂 and the best thing is the most seruced one 🙂 I bet the guy who opened the theme meant to ask for the more secure one :)
echo intval('-42'); // -42
echo intval(042); // 34
echo intval(1e10); // 1410065408
echo intval('1e10'); // 1
echo intval(0x1A); // 26
A? READ!
Edyka wrote: Not in the original post 🙂 the one by you can be ignored... that is just an example 😀 why not? intval returns only ints as I know? .... PS your PHP knowledge is great, but your english could use some training 🙂 PHP: intval - Manual returns only integers .. 🙂 and the best thing is the most seruced one 🙂 I bet the guy who opened the theme meant to ask for the more secure one :)
thanks@ Edyka
i mean which one is more secure?