Hi folks!
I'm new to PHP/mysql.
I created a db with one table (using PhpMyAdmin). The table is called
'addressbook' and the base 'mabase'.
I can very well read the table and display it very neatly using the below
code, but I CAN'T write new entries using the code in the second page (end
of mail)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PAGE THAT "WORKS"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<html>
<head>
<title>Carnet d'adresses</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body { font-family: Arial, Helvetica, sans-serif; font-size: 10pt; color:
#000000; letter-spacing: 0.1em; background:#efefef}
.NomPrenom { font-family: Arial, Helvetica, sans-serif; font-size: 10pt;
color: #000000; font-weight:bold; letter-spacing: 0.1em; }
hr {height:1px; color:#BBBBBB}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?
$host = "localhost";
$user = "";
$password = "";
$database = "mabase";
//==========================================================================
=====
// Display addressbook table content
//==========================================================================
=====
mysql_connect($host,$user,$password) or die("Impossible de se connecter � la
base de donn�es ".$database);
$result = mysql_db_query($database,"select * from addressbook");
while ($row = mysql_fetch_object($result))
{
if($row->prenom != "")
{
echo "<span class=\"NomPrenom\">".$row->prenom."</span>";
}
if($row->nom != "")
{
echo "<span class=\"NomPrenom\"> ";
echo $row->nom."</span>";
}
if($row->teldomicile != "")
{
echo "<br>\n";
echo "<img src=\"/interface/icons/domicile_phone.gif\"
align=\"absbottom\"> \n";
echo $row->teldomicile;
}
if($row->telmobile != "")
{
echo "<br>\n";
echo "<img src=\"/interface/icons/mobile.gif\"
align=\"absbottom\"> \n";
echo $row->telmobile;
}
if($row->telbureau != "")
{
echo "<br>\n";
echo "<img src=\"/interface/icons/bureau.gif\"
align=\"absbottom\"> \n";
echo $row->telbureau;
}
if($row->email != "")
{
echo "<br>\n";
echo "<img src=\"/interface/icons/email.gif\"
align=\"absbottom\"> \n";
echo "<a href=\"mailto:".$row->email."\">".$row->email."</a>";
}
if(($row->rue != "") || ($row->codepostal != "") || ($row->ville != "") ||
($row->pays != ""))
{
echo "<br>\n";
echo "<img src=\"/interface/icons/adresse.gif\"
align=\"absbottom\"> \n";
}
if($row->rue != "")
{
echo $row->rue;
echo " - ";
}
if($row->codepostal != "")
{
echo $row->codepostal;
echo " ";
}
if($row->codepostal != "")
{
echo $row->ville;
echo ", \n";
}
if($row->pays != "")
{
echo $row->pays;
}
echo "<br><br><br><hr><br><br><br>\n";
}
mysql_free_result($result);
mysql_close();
// END Display addressbook table content
?>
</body>
</html>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PAGE THAT "WORKS" - END -
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PAGE THAT "DOESN'T WORK"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?
$host = "localhost";
$user = "";
$password = "";
$database = "mabase";
mysql_connect($host,$user,$password);
$nom = "Dupont";
$prenom = "Jean";
$ok = mysql_db_query($database, "insert into addressbook (nom,prenom) values
('$nom','$prenom')");
?>
</body>
</html>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PAGE THAT "DOESN'T WORK" - END -
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
After that when I look at my page where I display the addressbook table, I
see nothing new, neither does it appear anywhere in PhpMyAdmin.
I don't get it!
But, again, I'm a newbie.
Is there a problem with the fact that I provide an empty user/password? I
don't recall having given any user name and password durng MySQL
installation.
If there is one, where can I find it? Or do I have to re-install???
Hope it's just a newbie syntax mistake though...
Thanks for reading anyway!
Cheers,
S�bastien
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]