Jump to content

[SOLVED] Get data from a DB


forumnz

Recommended Posts

I really can't figure out whats wrong with this code??

 

<?php
// Make a MySQL Connection
mysql_connect("localhost", "designervi_mag", "***") or die(mysql_error());
mysql_select_db("designervi_mag") or die(mysql_error());

// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM mag") 
or die(mysql_error());  

// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo stg1; 

} 

?>

Link to comment
https://forums.phpfreaks.com/topic/49403-solved-get-data-from-a-db/
Share on other sites

<?php

 

$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');

if (!$link) {

    die('Not connected : ' . mysql_error());

}

 

// make foo the current db

$db_selected = mysql_select_db('foo', $link);

if (!$db_selected) {

    die ('Can\'t use foo : ' . mysql_error());

}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.