Page 1 of 1
Easy input into tables
Posted: Wed Feb 11, 2004 3:18 am
by phpnewbie1985
Hi, as you can probably tell my the name im new to PHP so be gentle! :S I want to have a text file on server which i can update from time to time and then a page called "table.php" will load each row in the text file into a new row in a table.. is this possible? if so could somebody please explain how i could do this?
Many thanks
Chris
Posted: Wed Feb 11, 2004 3:24 am
by Dr Evil
Of course this is all possible. But would you not like to use a database instead. You can update it very easily. Have a look around for a few tutorials and don't hesitate: ask here for directions.
Depends how newbie you are
thisis quite good.
Dr Evil
Posted: Wed Feb 11, 2004 3:26 am
by malcolmboston
flat files are very useful in amny circumstances
you can find alot of information
here
HELLP!!
Posted: Wed Feb 11, 2004 6:25 am
by phpnewbie1985
I have made a database called matrix_lists with a table called nokia6600 and a record in it. now when i try to retrieve the data from the database it says Connected Successfully, Could not select database... I got the code striaght from php.net and im just confused now!!!
HELP!
Code: Select all
<?php
/* Connecting, selecting database */
$link = mysql_connect("localhost", "username", "password")
or die("Could not connect : " . mysql_error());
echo "Connected successfully";
mysql_select_db("matrix_lists") or die("Could not select database");
/* Performing SQL query */
$query = "SELECT * FROM nokia6600";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
/* Printing results in HTML */
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $name) {
echo "\t\t<td>$name</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
/* Free resultset */
mysql_free_result($result);
/* Closing connection */
mysql_close($link);
?>
Many thanks
Chris
Posted: Wed Feb 11, 2004 6:28 am
by malcolmboston
there are 2 possible reasons that i can think of
1- the user you are connecting to mysql with does not have permissions for this 'database'
2- your database is spelt wrong (or case is wrong)
coincidentally, your syntax is correct
Posted: Wed Feb 11, 2004 6:28 am
by JayBird
first things first. Your DB is definately called matrix_lists, you haven't spelt it wrong or anything like that have you?
Mark
Posted: Wed Feb 11, 2004 6:29 am
by twigletmac
Try changing:
Code: Select all
mysql_select_db("matrix_lists") or die("Could not select database");
to
Code: Select all
mysql_select_db("matrix_lists") or die("Could not select database".'<p>'.mysql_error().'</p>');
to see if you get a more useful error message.
Mac
WOOHOO
Posted: Wed Feb 11, 2004 7:11 am
by phpnewbie1985
Brilliant! i had not assigned that user to database... dumb ass i am! :S thanks for all your help!

its much appreciated! thats why i love this forum such speedy replies!
Chris