Closed Thread Icon

Topic awaiting preservation: Php sql Pages that link to <a href="https://ozoneasylum.com/backlink?for=11892" title="Pages that link to Topic awaiting preservation: Php sql" rel="nofollow" >Topic awaiting preservation: Php sql\

 
Author Thread
Osaires
Paranoid (IV) Inmate

From: oslo, Norway
Insane since: Aug 2001

posted posted 09-28-2001 00:32

i'm just wondering what is roung:
<?
$db = mysql_connect("localhost", "hi", "hi");
mysql_select_db("osaires",$db);

$sql="SELECT * FROM authors";
$result=mysql_query($sql,$db);
$row = mysql_query($sql,$db);

$aid = $row["aid"];
$name = $row["name"];
$email = $row["email"];
echo "Author $aid <a href=\"mailto:$email\">$name</a>";
?>

it's not working and i know the username, localhost and password it corect, and the database name is also right
do you know what it's it?



[This message has been edited by Osaires (edited 09-28-2001).]

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 09-28-2001 00:46

Couple of things
$row = mysql_query($sql,$db);

This doesn't return an associative array what you want is this
$row = mysql_fetch_array($result);

That should work. however you are just going to get the first author if there is more than one you need to put this in a loop

while ($row = mysql_fetch_array($result)) {

$aid = $row["aid"];
$name = $row["name"];
$email = $row["email"];

}



:[ Computers let you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila. ]:

Osaires
Paranoid (IV) Inmate

From: oslo, Norway
Insane since: Aug 2001

posted posted 09-28-2001 00:52

Thanks bitdamaged, i have thinking, traying, rewritng this script for 2 hours, it's my first time using php and sql together it's realy cool thanks.


Osaires
Paranoid (IV) Inmate

From: oslo, Norway
Insane since: Aug 2001

posted posted 09-28-2001 14:35

Ok, how do i write to a database ?

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 09-28-2001 15:10

ok, since you're using mysql look into it's documentation.
Insert (into) should do the trick.



Tyberius Prime
"If you can't make one up, use this witty quote instead".

jiblet
Paranoid (IV) Inmate

From: Minneapolis, MN, USA
Insane since: May 2000

posted posted 09-28-2001 16:42

More specifically read the MySQL Insert Documentation

-jiblet

« BackwardsOnwards »

Show Forum Drop Down Menu