Re: newbie question
| From: | Rafael Mora | Date: | Tue, 04 Aug 2020 01:21:36 +0000 |
| Subject: | Re: newbie question | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-327250@lists.php.net to get a copy of this message | ||
The if bracket, yes.
Bye!
On Mon, Aug 3, 2020 at 20:20 Fernando Fiore <no5software@gmail.com> wrote:
> i forgot a bracket, damn. sorry guys;
>
> Em seg., 3 de ago. de 2020 às 22:19, Fernando Fiore <no5software@gmail.com>
> escreveu:
>
>> Awesome, thanks!
>>
>> Em seg., 3 de ago. de 2020 às 22:16, Aziz Saleh <azizsaleh@gmail.com>
>> escreveu:
>>
>>> Don't forget to never store passwords in plain text in the DB. Here is a
>>> few better ways of doing it:
>>>
>>>
>>>
>>> https://stackoverflow.com/questions/14798275/best-way-to-store-passwords-in-mysql-database
>>>
>>> Also you might be better off using PDO (but that's just my opinion).
>>>
>>> On Mon, Aug 3, 2020 at 9:12 PM Rafael Mora <rafael.mora.guti@gmail.com>
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> Maybe you should use the char ' in the values:
>>>> ("INSERT INTO users (nick, email, pw) VALUES('$nick',
>>>> '$mail',
>>>> '$pw');");
>>>>
>>>> You should also copy and paste the error you are getting.
>>>>
>>>> Bye!
>>>>
>>>>
>>>> ----------------------------------------------
>>>> Atentamente/Best regards
>>>>
>>>> Rafael Mora
>>>> Cel/Mob: +58-414-493.31.39
>>>> Cel/Mob: +57-321-755.37.69
>>>> Twitter @titanve
>>>>
>>>>
>>>> On Mon, Aug 3, 2020 at 8:06 PM Fernando Fiore <no5software@gmail.com>
>>>> wrote:
>>>>
>>>>> why this simple database operation does not work
>>>>> function AddToUsersTable($mail,$nick,$pw) // $mail is an email add
>>>>> {
>>>>> $db = new
>>>>> mysqli("localhost","root","","mydb");
>>>>>
>>>>> if($db){
>>>>> $mail = $db->real_escape_string($mail);
>>>>> //print($mail . "</br>");
>>>>> $nick = $db->real_escape_string($nick);
>>>>> $pw = $db->real_escape_string($pw);
>>>>> $q = $db->query("INSERT INTO users (nick, email, pw)
>>>>> VALUES($nick, $mail, $pw);");
>>>>> if($q)
>>>>> return true;
>>>>> else{ /* it fails here *;
>>>>> print($db->error);
>>>>> return false;
>>>>> }
>>>>>
>>>>> }
>>>>> else{
>>>>> print("failed to connect to db </br>");
>>>>> return false;
>>>>> }
>>>>>
>>>>> }
>>>>> // thanks in advance
>>>>>
>>>> --
----------------------------------------------
Atentamente/Best regards
Rafael Mora
Cel/Mob: +58-414-493.31.39
Cel/Mob: +57-321-755.37.69
Twitter @titanve