PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Thanks for taking the time to help,
I don't have all the code in front of me now but I'm not having a problem connecting to the database or table.
I've got checkers that tell me whether or not I've connected properly & also test $result like so.
If I change my query to something that won't give $result a true result from the table I'll get the error
so $result must have the answer but I can't figure how to get it out.
I hate to sound stupid, I read it but I just don't get it.
I don't understand the mysql_fetch_array function.
I'm trying to learn this stuff on my own & I'm not doing too good yet.
I was hoping someone could show me in one line what i needed to do but evidently that ain't happening.
My plan is to design a program in php that I expect to take about a year to complete so the extra time it takes until I learn how to get the answer to my original question won't make much difference anyhow. At least If I ever figure it out I'll understand it.
<?php
// Example
// Here we define how we are going to display errors
error_reporting(E_ALL);
ini_set("display_errors", 1);
$db_hostname = "thehost"; //usually "localhost is the default"
$db_username = "youusername"; //your user name
$db_pass = "youpassword"; //the password for your user
$db_name = "thedatabase"; //the name of the database
// We try to open a connection to our DB here.
$link = mysql_connect($db_hostname,$db_username,$db_pass) or die ('Db Connection Error: ' . mysql_error());
// We select the DB to work with
mysql_select_db($db_name, $link) or die('DB Selection Error :' . mysql_error());
// Here we define our query (tbId & tbName are only field examples)
$query ="select tbId,tbName from ourtabla";
// Here the query is executed and results are returned in a recordset
$rs = mysql_query($query, $link) or die("Query Fail : " . mysql_error());
// Here we use a while loop to retieve the rows from the recordset
// and do whatever we want with the values
while ($row = mysql_fetch_assoc($rs))
{
echo "Id = " . $row['tbId'] . "<br />";
echo "Name = " . $row['tbName'] . "<br />";
}
// We close the DB link (even when is not neccesary, because it is closed
// automatically when the php script finish
mysql_close($link);
?>