Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

PHP question

Gattz Gilman
Banned from RealLife :/
Join date: 29 Feb 2004
Posts: 316
05-04-2005 21:10
im a complete noob at php. I understand how it should the basic mechanics of it work, but not sure of how code for the purpose i have. I want to use it to put updates on my webpage. So, instead of having to manualy put a new table, i'd like to have it check the MySQL database, where each table is a new update. And it would show the last 5 or 10 updates. Ive looked online, but i cant find anything similiar to this. and what i do have doesnt seem to work.

Here is the code im using now as a test:
CODE

<?
$user="username";
$password="password";
$database="databasename";
mysql_connect("hostname",$user,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query="SELECT * FROM udpate5-4-05";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

echo "<b><center>Database Output</center></b><br><br>";

$i=0;
while ($i < $num) {

$header=mysql_result($result,$i,"header");
$desc=mysql_result($result,$i,"desc');

echo "$header $desc";
$i++;
}
?>

but all i get is an error message:
Parse error: parse error, unexpected T_VARIABLE in /home/.danila/username/hostname.com/phptest/test.php on line 23

If someone would be willing to help me out to get the code done, id be more then happy to pay for your time. I have only 10k. Or if you can tell me where i can find something either similar or where i can find out how to do this.
_____________________
Pete Fats
Geek
Join date: 18 Apr 2003
Posts: 648
05-04-2005 21:25
ha! I was staring at this for a good 5 min before I noticed. Change this line:

$desc=mysql_result($result,$i,"desc');

Notice your ' instead of a " at the end. Then it should work.
_____________________
Gattz Gilman
Banned from RealLife :/
Join date: 29 Feb 2004
Posts: 316
05-04-2005 22:55
hmm, mow its a problem with my database. And i swear the this thing doesnt seem to make any sense @_@. You wouldnt happen to know of a good tutorial on it? Cause im just getting lost in this.
_____________________
Pete Fats
Geek
Join date: 18 Apr 2003
Posts: 648
05-04-2005 22:57
I personally like this one. It happens to be the number one google result for php mysql, but of all the ones I read while learning, it seems to be the most straight forward.
_____________________
Huns Valen
Don't PM me here.
Join date: 3 May 2003
Posts: 2,749
05-06-2005 15:03
mysql is simultaneously great and also the devil. good luck with it.
Frans Charming
You only need one Frans
Join date: 28 Jan 2005
Posts: 1,847
05-06-2005 18:02
What i think you say, is that you are creating a table for every update on your site.
That is not how a database is intended. The intent is that you design a set of tables that can hold all the information you need. And only create new tables for new sets of information.

How about, create table that has all the colums that your udpate*** table already have, and add a colum named date and of the type date.
When you input new rows in the table you will add the date.
And when you retrieve the information you just put a where clause in the statement.
example:
SELECT * FROM udpate where date = 2005-05-04

I hope this is simple enough to understand. And try to find some good information about sql and database design.