Log in

View Full Version : Totally New



tov
05-07-2006, 01:07 AM
Hi,

I think I'm trying to learn the DB part of Php.

So far I've made a DBtable with phpMyAdmin
it has three parts...
1- ID#
2- Title
3- Body

My thinking is to retrieve and display the data on a webpage.

I made a config file - looks like this...



<?php
$host = "localhost";
$user = "xxxxxx";
$password = "xxxxxx";
$database = "abcd_soblog";
?>

Next I'm woking on the grammer and syntax but I'm having a hard time of it.



<?php
require ('config.php');
$query = "SELECT * FROM 'ablog' LIMIT 0, 30";
?>

I've tried several variations


<?php
$host = "localhost";
$user = "xxxxxx";
$password = "xxxxxx";
$database = "abcd_soblog";
$result = mysql_query("SELECT abcd _soblog * FROM ablog",$db);
printf("title: %s<br>\n", mysql_result($result,0,"first"));
printf("body: %s<br>\n", mysql_result($result,0,"last"));
?>

I've got four books and it seems they jump from a simple echo statement - to complex DB schemas. Even the online tutorials seem to skip the kind of very basic step by step - ( understanding the baby steps ) - kind of tutorial I guess I need.

I would like to see a display of...


A Big Title

bla bla ipsum epsum bla bla body of text etc...

and then maybe something like showing all four entries n the DBTable.

I'm hoping some kind person can help me get a grip on this, please.
:D

djr33
05-07-2006, 03:17 AM
http://www.php-mysql-tutorial.com/


I'm not sure what's wrong with your setup... but a couple things don't look right.

The main thing is that you totally lack any connection to a database.

Yeah, you've got your username and password, but you lack a connection to them.

use
$conn = mysql_connect(host,user,pass) (not sure on the order there)
then you must choose a database to work with...

this is all in the link above.

I really like the tutorial.

I noticed a week or two ago that the site was over its alloted bandwidth.... so.... hope it stays up.


by the way, I don't think you're wanting to use LIMIT 0, 30. That would return 30 results... not sure why you want that. I'm guessing you're using mysqladmin to work with your database... the syntax in there is specifically oriented for that setup, and won't translate directly. Though, I use it to figure out syntax sometimes myself.

tov
05-07-2006, 12:31 PM
Thanks,
I've not come across that one before.
My brother recommended the first one.
I'll give that a good going over later today. Thanks.

These are the ones I've looked over thus far...

http://www.webmonkey.com/webmonkey/99/21/index3a.html
http://us3.php.net/manual/en/function.mysql-query.php
http://techtuts.com/?view=tutorials&act=tutorial&id=506

djr33
05-07-2006, 08:13 PM
don't give up on php.net, though.

it's a very nice place to reference functions.

it's worthless as a tutorial if you have no clue, but it's great with examples and explanations for each individual function once you start needing to use them and find out what they do.
it's more of a resource than tutorial, though.