|
-
Sep 18th, 2003, 07:54 PM
#1
Thread Starter
Lively Member
poop (mysql) *RESOLVED*
PHP:
--------------------------------------------------------------------------------
<?php
$username = "morrowasted";
$password = "[edited]";
$hostname = "localhost";
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
print "Connected to MySQL<br>";
$selected = mysql_select_db("www",$dbh)
or die("Could not select first_test");
if (mysql_query("insert into people values('4','$name1','$post1')")) {
print "successfully inserted record";
}
else {
print "Failed to insert record";
}
mysql_close($dbh);
mysql_close($dbh);
?>
--------------------------------------------------------------------------------
PHP:
--------------------------------------------------------------------------------
<?php
$username = "morrowasted";
$password = "[edited]";
$hostname = "localhost";
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
$selected = mysql_select_db("www",$dbh)
or die("Could not select first_test");
$result = mysql_query("SELECT id, name,post FROM people");
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
echo "<div style='background:black;font:10pt;color:white'>";
echo "<center>";
print " Name:".$row{'name'}." <br>Comment:
".$row{'post'}."<br><br>";
echo "</center>";
print "</div>";
}
mysql_close($dbh);
?>
--------------------------------------------------------------------------------
PHP:
--------------------------------------------------------------------------------
<html>
<title> Post Comment </title>
</head>
<body bgcolor=black>
<form action="test.php" method="get">
Name: <input type="text" name="name1" value="Enter Username"><br>
Comment: <input type="text" name="post1" value="comment" size="20"><br>
<input type="submit" value="Post">
</form>
--------------------------------------------------------------------------------
everything works except im getting my "Failed to insert record" error (its not inserting it).
Last edited by morrowasted; Sep 18th, 2003 at 08:58 PM.

-morrowasted
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|