<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aakriti Sharma</title>
    <description>The latest articles on DEV Community by Aakriti Sharma (@aakriti_sharma).</description>
    <link>https://dev.to/aakriti_sharma</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F475335%2Fe6f88114-64ce-4af2-889a-998b27423c80.jpeg</url>
      <title>DEV Community: Aakriti Sharma</title>
      <link>https://dev.to/aakriti_sharma</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aakriti_sharma"/>
    <language>en</language>
    <item>
      <title>How to run PHP and link to MySQL using XAMPP</title>
      <dc:creator>Aakriti Sharma</dc:creator>
      <pubDate>Mon, 30 Nov 2020 12:49:19 +0000</pubDate>
      <link>https://dev.to/aakriti_sharma/how-to-run-php-and-link-to-mysql-using-xampp-57lh</link>
      <guid>https://dev.to/aakriti_sharma/how-to-run-php-and-link-to-mysql-using-xampp-57lh</guid>
      <description>&lt;p&gt;I spent 12 hours on the day of my presentation trying to figure this out so if you ask me what was the inspiration behind writing this post, it's to save someone from this plight.&lt;/p&gt;

&lt;h1&gt;
  
  
  Installing PHP:
&lt;/h1&gt;

&lt;p&gt;Go to &lt;a href="https://www.php.net/downloads.php"&gt;https://www.php.net/downloads.php&lt;/a&gt;&lt;br&gt;
I downloaded 7.2, on clicking on the link a zip folder gets downloaded, extract the files inside a folder PHP7 in the C drive.&lt;/p&gt;

&lt;p&gt;If you use VSCode, change php.validate.executablePath = "C://PHP7//php.exe" in settings.json &lt;br&gt;
Install the Code Runner Extension and run the file from terminal itself.&lt;/p&gt;

&lt;h1&gt;
  
  
  Installing XAMPP
&lt;/h1&gt;

&lt;p&gt;Go to &lt;a href="https://www.apachefriends.org/download.html"&gt;https://www.apachefriends.org/download.html&lt;/a&gt;&lt;br&gt;
and download the latest version of XAMPP, installation process begins, press Finish when it is done.&lt;/p&gt;

&lt;p&gt;Open XAMPP Control Panel&lt;br&gt;
Press Start for Apache and MySQL modules.&lt;br&gt;
The panel appears like: &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CbkYxCqw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3ihmq10ow60ttfnk4kk5.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CbkYxCqw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3ihmq10ow60ttfnk4kk5.PNG" alt="Control Panel"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Go to your browser and type localhost&lt;br&gt;
If the following screen appears , you have installed XAMPP successfully &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ia4BDs_o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/er2kn9wn5mhrj4ya4koe.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ia4BDs_o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/er2kn9wn5mhrj4ya4koe.PNG" alt="Dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Run PHP Files using XAMPP
&lt;/h1&gt;

&lt;p&gt;Go to C Drive -&amp;gt; xampp -&amp;gt; htdocs -&amp;gt; create a folder and store your php files there.&lt;/p&gt;

&lt;p&gt;Inside your browser go to localhost/your folder name/path to your php file and you will be able to see your output on the webpage.&lt;/p&gt;

&lt;h1&gt;
  
  
  Linking PHP to Database
&lt;/h1&gt;

&lt;p&gt;$host = "127.0.0.1";&lt;br&gt;
$username = "root";&lt;br&gt;
$pass = "foobar";&lt;br&gt;
$conn = mysqli_connect($host, $username, $pass, "speed_age");&lt;br&gt;
if(!$conn)&lt;br&gt;
{&lt;br&gt;
    echo 'could not connect'.mysqli_error();&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;The next error I encountered was root@localhost not connected using password if you do too go to XAMPP Control Panel -&amp;gt; Config button for Apache Module -&amp;gt; phpMyAdmin -&amp;gt; Section under Authentication type and info&lt;/p&gt;

&lt;p&gt;Change this line as $cfg['Servers'][$i]['password'] = 'your password';&lt;/p&gt;

&lt;p&gt;I have used foobar so I changed it to &lt;em&gt;$cfg['Servers'][$i]['password'] = 'foobar';&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you get the no database detected error go to Admin in MySQL Module -&amp;gt; Databases -&amp;gt; Create Database -&amp;gt;  Give the name as you used in your code , I used &lt;em&gt;speed_age&lt;/em&gt; in mine.&lt;/p&gt;

&lt;p&gt;For creating tables and manipulate data in rows use GUI or go to SQL tab right to Databases and run query.&lt;/p&gt;

&lt;p&gt;Thank you for reading , this is my first post let me know what you think :)&lt;/p&gt;

</description>
      <category>php</category>
      <category>mysql</category>
      <category>webdev</category>
      <category>database</category>
    </item>
  </channel>
</rss>
