View Single Post
Old 10-08-2021, 12:23 AM  
zerovic
Confirmed User
 
zerovic's Avatar
 
Industry Role:
Join Date: Apr 2010
Posts: 1,111
Hey,

Open up a new PHP file and do it like this

Quote:
$mysqli = new mysqli("localhost","username","password","database ");

if ($mysqli -> connect_errno) {
echo "Failed to connect to MySQL: " . $mysqli -> connect_error;
exit();
}

$data = mysqli_query($mysqli, "SELECT * FROM Recipe WHERE Ingredients REGEXP 'salt';");
while($result = mysqli_fetch_array($data)) {
//here goes the data
}
Let me know if this works. The main difference is how you connect to your db.

I just tried this on one of my scripts and it works like charm.

Also, in my case, using

Quote:
LIKE '%salt%'
was faster then

Quote:
REGEXP 'salt';
Tried it on a POS script I wrote for a few bars and restaurants in my town and here's the result

Quote:
SELECT * FROM `orders` WHERE `ordered_item` REGEXP 'cola';
Showing rows 0 - 24 (4683 total, Query took 0.0010 seconds.)

SELECT * FROM `orders` WHERE `ordered_item` LIKE '%cola%'
Showing rows 0 - 24 (4683 total, Query took 0.0007 seconds.)
Cheers,
z
zerovic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote