hey everybody, havent been on for a while. but i have a bit of an issue here:
I'm making a flash chat based with PHP and MySQL (finally.)
And right now im just trying to get used to connecting PHP with MySQL. there's always seemed to be problems whenever i do, hoping somebody can help me with this one.
(note: dont mind my immature notes... its only a test file)
Here's my php file:
Note: replaced my details with "secret" and for a very good reason.PHP Code:<?php
$con = mysql_connect("secret","secret","secret");
if (!$con)
{
die('Could not connect because you suck.');
}
mysql_select_db("jchee_chat", $con);
$sql = mysql_query("INSERT INTO Users (Username, Age)
VALUES ('$_POST[Username]', '$_POST[Age]')");
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "you were added!"
mysql_close($con);
?>
in case you wanna see where i get the POST variables "username" and "age" from, here's the form it comes from:
PHP Code:<html>
<head>
</head>
<body bgcolor=#CC9966>
<font size="100" face="Arial" color="#0066FF">
<form action="test1.php" method="post">
Username: <input type="text" name="Username" />
Age: <input type="text" name="Age" />
<input type="submit" />
</form>
</font>
</body>
</html>





Reply With Quote