V
V
Viplayer2019-10-02 20:47:39
PHP
Viplayer, 2019-10-02 20:47:39

Search by beginning of word sql and php?

I want to get the value at the beginning of the entered string... I wrote the following pseudo-query:

$second_name = $db_site->query("SELECT * FROM wp_users WHERE second_name = LIKE ('".$string."%') ")->fetch_assoc()['second_name'];

All code after this line dies, what's wrong, tell me please...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Northern Lights, 2019-10-02
@php666

you need to use match against

F
FanatPHP, 2019-10-03
@FanatPHP

If "dies" means "works slowly", then put the index.
If it dies, it means it stops working but does not give errors - you need to turn on error output, read it and fix it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question