$connection = mysql_connect( $host, $user, $password );
$dbconnect = mysql_select_db($database, $connection);
// Write a query
$sQuery = "SELECT `id`, `title` FROM `cds`";
// Execute query
$rResult = mysql_query($sQuery) or die (mysql_error());
// Retrieve the data
$aRows = array();
while ($aRow = mysql_fetch_array($rResult,MYSQL_ASSOC))
$aRows = $aRow;
// Display the data
foreach ($aRows as $aRow)
echo "id: " . $aRow['id'] . "<br />";
echo "title: " . $aRow['title'] . "<br />";
if not the root folder, where should I put my .sql files? Also how can I tell PHP to look in that location and communicate with my database?
Wiedmann wrote:A *.sql file is not a database which you can use with PHP. That's a dump which you must import into the MySQL server.
(Maybe more reading in a PHP/MySQL book...)
How does one import to the MySQL server?
MegaChriz wrote:For importing SQL-commands in MySQL I recommend to use phpMyAdmin.
1. Start XAMPP.
2. Go to http://localhost/phpmyadmin in your browser.
3. On the left of the screen a list of databases appears. Select a database.
4. A list of tables appears. On the top of the screen you see a tabbed menu with 'Structure', 'SQL', 'Search' and some other. If you click on 'SQL' you can just type your sql-commands there and execute them. If you click on 'Import', you can import a sql-file to execute.
Great thing about phpMyAdmin is that if the SQL-command is'nt quite right, you see an error message of phpMyAdmin after you've tried to execute the SQL-command.
Hope that this helps you.
Users browsing this forum: No registered users and 1 guest