Closed Thread Icon

Topic awaiting preservation: PHP Newbee (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=12060" title="Pages that link to Topic awaiting preservation: PHP Newbee (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: PHP Newbee <span class="small">(Page 1 of 1)</span>\

 
Blacknight
Bipolar (III) Inmate

From: INFRONT OF MY PC
Insane since: Dec 2001

posted posted 02-20-2002 18:44

ive started lerning php
ind im triieng to do a simple database output(newsscript)
but im sortof...dum

how does the readout work (i've got the connection right so far)
i dont want a finished script only something that gives me a clue of how it works

tutorial-links would be nice

Dark Phoenix
Paranoid (IV) Inmate

From: Harrow, Ontario, Canada
Insane since: Feb 2002

posted posted 02-20-2002 19:21

It's connected, and you want to know how to get the info out?

"No one's going to give you a map; you've got to walk your own path." = Hot Ice Hilda, Outlaw Star.

Blacknight
Bipolar (III) Inmate

From: INFRONT OF MY PC
Insane since: Dec 2001

posted posted 02-20-2002 19:32

jes thats right....i know no one will give me a map but a push in the right direction and some sites where to finde tutorials???

Dark Phoenix
Paranoid (IV) Inmate

From: Harrow, Ontario, Canada
Insane since: Feb 2002

posted posted 02-20-2002 19:40

Go to http://www.php.net and read the section on FTP functions.

Basically, all you have to do is connect, log in and then use ftp_put() to put the file where you want it.

Just make sure the folder allows writing.

"No one's going to give you a map; you've got to walk your own path." = Hot Ice Hilda, Outlaw Star.

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 02-20-2002 21:13

I don't see anything in the original request for FTP features....

If you're wanting to get a row of data out, you need to look at mysql_fetch_row

Dark Phoenix
Paranoid (IV) Inmate

From: Harrow, Ontario, Canada
Insane since: Feb 2002

posted posted 02-20-2002 21:15

Sorry; got mixed up with another request.

Do you know SQL?

And you should NEVER use mysql_fetch_row(); use mysql_fetch_array() instead.

"No one's going to give you a map; you've got to walk your own path." = Hot Ice Hilda, Outlaw Star.

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 02-20-2002 21:19

If you could give a little better discription of how your database is set up, what kind of database you are using, and what you want to display from it, we could probably help you a little better.


-Butcher-

[This message has been edited by butcher (edited 02-20-2002).]

Blacknight
Bipolar (III) Inmate

From: INFRONT OF MY PC
Insane since: Dec 2001

posted posted 02-21-2002 13:55

i'm using a sql Database and alli realy want is to have a newsscript that orders the Titles by date.

wats the difference between fetch_array and fetch_row?

Dark Phoenix
Paranoid (IV) Inmate

From: Harrow, Ontario, Canada
Insane since: Feb 2002

posted posted 02-21-2002 14:37

Did you set up the database tables?

"No one's going to give you a map; you've got to walk your own path." = Hot Ice Hilda, Outlaw Star.

Blacknight
Bipolar (III) Inmate

From: INFRONT OF MY PC
Insane since: Dec 2001

posted posted 02-21-2002 14:50

yes if done that

Blacknight
Bipolar (III) Inmate

From: INFRONT OF MY PC
Insane since: Dec 2001

posted posted 02-21-2002 15:01

my first try but i doesnt realy work
<?php
$server ="***";
$user="***";
$pass="***";
$dbase="***";
$conn= @mysql_connect($server, $user,$pass) or die ("Konnte verbindung zur db nicht herstellen");


mysql_select_db($dbase, $conn);

$ergebnis=mysql_query("SELECT * FROM News");
$datensatz=mysql_fetch_array($ergebnis); Ive also tried fetch_row same result
print "$datensatz";

mysql_close($conn);
?>


But the output i get ..lok at http://www.wrightone.org/news.php



[This message has been edited by Blacknight (edited 02-21-2002).]

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 02-21-2002 15:02

www.php.net/manual is your all time number 1 ressource to go!

database output you want?

well basics steps to do so:

#connect to database - mysql_connect()
#select db - mysql_select_db()
#make query - mysql_query()
#fetch your results - mysql_fetch_array()
#do what you want with your data.

note: everytime you make mysql_fetch_array you get the data of the next row in an array.

any more questions? just ask...

edit: uhhh, simultaneous post.



[This message has been edited by GRUMBLE (edited 02-21-2002).]

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 02-21-2002 15:05

try:

print "$datensatz[0]";

cause you are trying to output an array. you have to access every element of the array.

Blacknight
Bipolar (III) Inmate

From: INFRONT OF MY PC
Insane since: Dec 2001

posted posted 02-21-2002 15:06

hehe works partly ..but how do i get all the data in the tablerow ??

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 02-21-2002 15:09

for ($i=0;$i<count($datensatz);$i++) {
print "$datensatz[$i]<p>";
}

here we go....
mess around with the script n variables if it doesnt work.

edit: forgot a $

[This message has been edited by GRUMBLE (edited 02-21-2002).]

Blacknight
Bipolar (III) Inmate

From: INFRONT OF MY PC
Insane since: Dec 2001

posted posted 02-21-2002 15:44

so the script now reads one dataset but it doesnt erad out all (like in a newsscript)

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 02-21-2002 16:04

as i said above, you have to do mysql_fetch_array everytime you want to access the next row.
the most common way is to put a while around your for:

while ($datensatz=mysql_fetch_array($ergebnis)) {
for ($i=0;$i<count($datensatz);$i++) {
print "$datensatz[$i]<p>";
}
}

Blacknight
Bipolar (III) Inmate

From: INFRONT OF MY PC
Insane since: Dec 2001

posted posted 02-21-2002 16:16

hmm no changes http://www.wrightone.org/news.php

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 02-21-2002 16:24

i dont see much there.
can you send me the php file or post it here?

Blacknight
Bipolar (III) Inmate

From: INFRONT OF MY PC
Insane since: Dec 2001

posted posted 02-21-2002 16:36

<?php
$server ="***";
$user="***";
$pass="***";
$dbase="***";
$conn= mysql_connect($server, $user,$pass) or die ("Konnte verbindung zur db nicht herstellen");


mysql_select_db($dbase, $conn);

$ergebnis=mysql_query("SELECT * FROM News");
$datensatz=mysql_fetch_array($ergebnis);
while ($datensatz=mysql_fetch_array($ergebnis)) {
for ($i=0;$i<count($datensatz);$i++) {
print "$datensatz[$i]<p>";
}
}


php mysql_close($conn); ?>


i know what you see is youst the script itself ..i havent done much mor yet


[This message has been edited by Blacknight (edited 02-21-2002).]

[This message has been edited by Blacknight (edited 02-21-2002).]

Dark Phoenix
Paranoid (IV) Inmate

From: Harrow, Ontario, Canada
Insane since: Feb 2002

posted posted 02-21-2002 16:40

Forgot to mention that; use a while loop:

while($row = mysql_fetch_array(*pointer to the query))
{
*Display the stuff using $row[]
}

That'll display everything.

"No one's going to give you a map; you've got to walk your own path." = Hot Ice Hilda, Outlaw Star.

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 02-21-2002 16:48

hmmm. dont see any errors there...
but kill the line: $datensatz=mysql_fetch_array($ergebnis);
before the while loop, cause otherwise you are fetching twice and will start with the second row.

how many rows do you have in your table?

Blacknight
Bipolar (III) Inmate

From: INFRONT OF MY PC
Insane since: Dec 2001

posted posted 02-21-2002 16:58

now youve confused me

my script
<?php
$server ="***";
$user="***";
$pass="***";
$dbase="***";
$conn= mysql_connect($server, $user,$pass) or die ("Konnte verbindung zur db nicht herstellen");


mysql_select_db($dbase, $conn);

$ergebnis=mysql_query("SELECT * FROM News");
$datensatz=mysql_fetch_array($ergebnis);
while ($datensatz=mysql_fetch_array($ergebnis)) {
for ($i=0;$i<count($datensatz);$i++) {

}
}
while($row = mysql_fetch_array($ergebnis))-------i keep geting an error in this line
{
print $row[0];
}


mysql_close($conn); ?>



[This message has been edited by Blacknight (edited 02-21-2002).]

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 02-21-2002 17:00

maybe because you are already at the end of your mysql-table.
once again the question: how many rows do you have in your mysql-table?

Blacknight
Bipolar (III) Inmate

From: INFRONT OF MY PC
Insane since: Dec 2001

posted posted 02-21-2002 17:06

4: Title Content User Date

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 02-21-2002 17:09

i think these are the columns. i meant the rows. (how many entries)

and as i said above, kill that line.

Blacknight
Bipolar (III) Inmate

From: INFRONT OF MY PC
Insane since: Dec 2001

posted posted 02-21-2002 17:10

at the moment ive got 2 but those will increase

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 02-21-2002 17:16

hmmm... that is really strange.
i cant see the problem right now.
did you remove the line: $datensatz=mysql_fetch_array($ergebnis);
before the while already and still get that error?

Dark Phoenix
Paranoid (IV) Inmate

From: Harrow, Ontario, Canada
Insane since: Feb 2002

posted posted 02-21-2002 17:18

Why are you counting and then going back to print?

First of all, only call mysql_fetch_array() in a while loop.

Each time you call it, perform every action you want to perform on it then; don't call it twice. Once you reach the end of the database, you'll have to requery it; so don't.

The count just seems useless to me. Do you need to count for some reason?

"No one's going to give you a map; you've got to walk your own path." = Hot Ice Hilda, Outlaw Star.

ASP Newbee Programmer
Nervous Wreck (II) Inmate

From: Carinthia
Insane since: Jan 2002

posted posted 02-21-2002 17:20

Hai Blacknight!

I´ve read your posts.
Why is it so hard to understand this.
I know you know more. So don´t play the stupid little boy.

Edefix

Blacknight
Bipolar (III) Inmate

From: INFRONT OF MY PC
Insane since: Dec 2001

posted posted 02-21-2002 17:21

no i dont have to count..i joust wqant all the datasets to be read out

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 02-21-2002 17:38

There is also nothing wrong with using mysql_fetch_row if you are only going to be returning a single row. While start a loop for one cycle?

Dark Phoenix
Paranoid (IV) Inmate

From: Harrow, Ontario, Canada
Insane since: Feb 2002

posted posted 02-21-2002 18:19

Because in this case, odds are it won't be one cycle.

And take out the for loop section completely.

"No one's going to give you a map; you've got to walk your own path." - Hot Ice Hilda, Outlaw Star.

Blacknight
Bipolar (III) Inmate

From: INFRONT OF MY PC
Insane since: Dec 2001

posted posted 02-21-2002 18:22

w´hy take it out wat would it change ...i wont to understand what im doing to...thx for all you

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 02-21-2002 18:41

having a look at: http://www.wrightone.org/news.php
it seems to work now, right?

Blacknight
Bipolar (III) Inmate

From: INFRONT OF MY PC
Insane since: Dec 2001

posted posted 02-21-2002 20:27

yes it workes ive youst have to see how i can formate it *gG*

« BackwardsOnwards »

Show Forum Drop Down Menu