How to connect MySQL db using new XAMPP

0 votes

What is the best way to connect and query in MySQL using XAMPP? And please tell me how to  implement PDO in the below script.

<?php
    $key = $_GET['key'];
    $array = array();
    $con = mysql_connect("localhost", "root", "");
    $db = mysql_select_db("search", $con);

    $query = mysql_query("select * from ajax_example where name LIKE '%{$key}%'");

    while ($row = mysql_fetch_assoc($query)) {
        $array[] = $row['name'];
    }
    echo json_encode($array);
?>

Jun 26, 2022 in PHP by narikkadan
• 63,600 points
302 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
1 answer

What is Php Mysql Database? How php connect to database?

Hello kartik, MySQL is the most popular database ...READ MORE

answered Feb 25, 2020 in PHP by Dey
1,132 views
0 votes
1 answer

How to retrieve or obtain data from the MySQL database using PHP?

Hello kartik,  Actually there are many functions that  ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,840 points
3,357 views
0 votes
1 answer

How can I connect to a Tor hidden service using CURL in PHP?

Hello @kartik, I use Privoxy and cURL to scrape Tor ...READ MORE

answered May 19, 2020 in PHP by Niroj
• 82,840 points
5,318 views
0 votes
1 answer

How to get a list of user accounts using the command line in MySQL?

Hello @kartik, Use this query: SELECT User FROM mysql.user; Which ...READ MORE

answered Aug 18, 2020 in PHP by Niroj
• 82,840 points
1,566 views
0 votes
1 answer

How can I connect to MySQL in Python 3 on Windows?

Hello @kartik, You should probably use pymysql - Pure Python ...READ MORE

answered Aug 20, 2020 in PHP by Niroj
• 82,840 points
946 views
0 votes
1 answer

How to create virtual column using MySQL SELECT?

Hello, Something like: SELECT id, email, IF(active = 1, ...READ MORE

answered Oct 20, 2020 in PHP by Niroj
• 82,840 points
3,510 views
0 votes
2 answers

Define a SQL query? What is the difference between SELECT and UPDATE Query? How do you use SQL in SAS?

HI.. SQL is Structured Query Language, which is ...READ MORE

answered Aug 8, 2020 in PHP by anonymous
10,540 views
0 votes
1 answer

Why is not preferable to use mysql_* functions in PHP?

The reasons are as follows: The MySQL extension: Does ...READ MORE

answered Sep 7, 2018 in Database by DataKing99
• 8,250 points
1,268 views
0 votes
2 answers
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP