I
I
Ilya2017-07-29 12:37:26
PHP
Ilya, 2017-07-29 12:37:26

Do I need to write or die in a sql query?

In PHP, I write sql queries like this:
4165aa9f44b14f4ab2a54d3f4e760702.jpg
I saw that others add this thing to the query: or die("Can't connect."). Does it need to be written? Necessarily?
I also write at the end: , $db). And is it necessary?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Tikhomirov, 2017-07-31
@sidorchik

or die are added when you need to stop the script on an error, and in brackets the actual text that will be displayed. But, as colleagues unsubscribed above, it is better to use PDO

S
SagePtr, 2017-07-29
@SagePtr

Discover PDO

T
ThunderCat, 2017-07-29
@ThunderCat

Boy, in what library did you find that ancient sinister spellbook of black sorcerers?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question