Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
srednatonmi
Forum Newbie
Posts: 15 Joined: Wed Mar 19, 2008 10:01 pm
Post
by srednatonmi » Sun Mar 23, 2008 1:32 pm
Moderators please read before locking, this is a different topic then my other post and the password user name is not real.
I am in charge of updating penfieldbooks.com. All of the items in their online store are stored in a database, therefore, I need to find the database to affect changes. I'm a designer, not a coder, so this is not my usual territory. The control panel on the site (plesk) shows no database.
I have a file called db_access.php which includes username, password etc (Not real information, just similar):
Code: Select all
<?php
$db_uid = "penfield4klkf";
$db_pswd = "ls7lag";
$db_name = "penfield4llkf";
?>
but I have no knowledge on how to implement it to get to the database. I am confident I can handle the changes within the database, however, I do not have the knowledge to access it. What can I do?
Thank you,
Anders
flying_circus
Forum Regular
Posts: 732 Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR
Post
by flying_circus » Sun Mar 23, 2008 4:56 pm
Anders,
This is really not very clear, for several reasons. First, what you have posted are just variables. It does not indicate that it actually access's any database at all. Second, there is no way (for us) to know what kind of a database you are accessing, or if you are accessing it. It could be Microsoft SQL, MySQL, PostgreSQL, or any other RDBMS, XML or Text files. You either need to give us more code, or look for clues. For example, if it's a MySQL database, you will have something like "mysql_connect" or "mysqli_connect" in your code somewhere.
Sorry, but given the information presented, it is impossible to figure out the solution.
srednatonmi
Forum Newbie
Posts: 15 Joined: Wed Mar 19, 2008 10:01 pm
Post
by srednatonmi » Sun Mar 23, 2008 8:36 pm
Thank you flying circus. Looking at the code, it appears to be just standard mysql. Here is the code that tells me that:
Code: Select all
<?php include("includes/copyright.php"); ?>
<?php
$page = "home";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Penfield Press - Home Page</title>
<meta name="robots" content="index, follow">
<meta name="description" content="">
<meta name="Keywords" content="">
<link rel="stylesheet" href="stylesheet/penfield.css" type="text/css">
<script src="javascript/javascripts.js"></script>
</head>
<body marginheight="0" marginwidth="0">
<table width="725" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#ffef00">
<tr>
<td background="images/side_background.gif" bgcolor="ffef00" width="25" rowspan="3"><img src="images/empty.gif" width="25" height="1" alt="" border="0"></td>
<td><img src="images/empty.gif" width="1" height="3" alt="" border="0">
<table width="700" border="0" cellspacing="0" cellpadding="1" bgcolor="#000099">
<tr>
<td colspan="2" valign="top" height="63"><?php include("includes/header.php"); ?></td>
</tr>
<tr>
<td colspan="2" align="center" height="20" bgcolor="#ffef00" class="blueText"><!--<b>215 Brown Street, Iowa City, Iowa 52245</b><br /><b>Phone: 319-337-9998 | Fax: 319-351-6846 | Toll Free: 1-800-728-9998</b><br />--><b>Distributing Books of Ethnic Interest for 29 Years 1979-2008</b></td>
</tr>
<tr>
<td align="left" valign="top" width="155" height="100%">
<?php include("includes/nav.php"); ?>
</td>
<td align="left" valign="top" width="100%">
<table width="550" height="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
<tr bgcolor="#FFFFFF">
<td align="left">
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="3" align="center" bgcolor="#ffffff">
<tr>
<td align="right" class="dateText" bgcolor="#ffffff" valign="bottom"><?php include("includes/date.php"); ?><img src="images/empty.gif" width="20" height="1" alt="" border="0"></td>
</tr>
</table>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td align="center" height="100%" bgcolor="#ffffff">
<!-- main content table -->
<table width="100%" border="0" cellspacing="0" cellpadding="10" align="center" bgcolor="#ffffff">
<?php
// ############################################################################ //
// SET THIS ADDRESS TO THE CGI-BIN DIRECTORY ON THE SERVER + "db_access.php" //
// THIS IS THE DATABASE ACCESS INFO //
// ############################################################################ //
include("/var/www/vhosts/penfieldbooks.com/httpdocs/db_access.php");
// ############################################################################ //
$dbConn = @mysql_connect("localhost",$db_uid,$db_pswd);
if (!$dbConn)
{
print("Error 1: Could not access Database.");
exit;
}
mysql_select_db($db_name,$dbConn) or die("Couldn't open $db: ".mysql_error());
$query = "SELECT title, teaser, body, footer FROM article WHERE type_id = '6' AND status_id = '1'";
$result = mysql_query($query,$dbConn) or die("");
while ($result_set = mysql_fetch_object($result))
{
$title = $result_set->title;
$teaser = $result_set->teaser;
$body = $result_set->body;
$footer = $result_set->footer;
?>
<tr>
<td class="title" colspan="2" align="center"><b><?php print($title); ?></b></td>
</tr>
<tr>
<td class="mainText" align="center" colspan="2"><?php print($body); ?>
<p><br />
<?php
if ($footer != "")
{
?>
<?php print($footer); ?>
<?
}
}
mysql_close($dbConn);
?>
</p>
<tr>
<td class="redTitle" align="center" colspan="2"><a href="book_store.php" class="titleLink">Click here to enter our Online Book Store</a></td>
</tr>
<tr>
<td align="left" width="47%" valign="top" colspan="2"><img src="images/empty.gif" width="1" height="10" alt="" border="0"><br />
<?php include("includes/homePage_headlines.php"); ?>
<br /><br /><br /><br /></td>
</tr>
</table>
<!-- end main content table -->
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td background="images/side_background.gif" bgcolor="ffef00" width="25" rowspan="3"><img src="images/empty.gif" width="25" height="1" alt="" border="0"> </td>
</tr>
<tr>
<td class="copyText" align="center" valign="middle"><img src="images/empty.gif" width="1" height="18" alt="" border="0" align="absmiddle"><?php include("includes/copyright_footer.php"); ?></td>
</tr>
</table>
</body>
</html>
I still don't know how to connect to the mysql database though.
Anders
flying_circus
Forum Regular
Posts: 732 Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR
Post
by flying_circus » Mon Mar 24, 2008 5:13 pm
Anders,
This is the relevant information. $dbConn is your db connection. Once connected, it is running a query and then stepping through each row of data (the while statement).
If you need to see the database structure, you can do it using sql. For example, if you want to see what the database servers structure looks like, you could do something like this:
Code: Select all
<?php
$dbConn = @mysql_connect("localhost",$db_uid,$db_pswd);
$getDbs = mysql_query("SHOW DATABASES");
while($db = mysql_fetch_row($getDbs)) {
print 'Database Name: ' . $db[0] . '<br>';
mysql_select_db($db[0]);
$getTables = mysql_query("SHOW TABLES");
while ($table = mysql_fetch_row($getTables)) {
print ' Table Name: ' . $table[0] . '<br>';
$getColumns = mysql_query("SHOW COLUMNS FROM " . $table[0]);
while ($column = mysql_fetch_row($getColumns)) {
print ' Column Info: ' . $column[0] . ' - ' . $column[1] . ', ' . $column[2] . ', ' . $column[3] . ', ' . $column[4] . '<br>';
}
}
print '<br>';
}
?>