Overclock.net banner
1 - 2 of 2 Posts

· Banned
Joined
·
2,261 Posts
Discussion Starter · #1 ·
Code:
Code:
[CODE]
<?php
$con = mysql_connect("localhost","alpha_coll","college");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("alpha_coll", $con);

$sql="INSERT INTO Users (UserID, FirstName, LastName, Age, Username, Password)
VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[age]','$_POST[username]','$_POST[password]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added.";

mysql_close($con)

header("refresh: 5; index.php?page=showusers");

?>
[/CODE]
adduser.php

Apparently, on line 22, there's an error
I can't see it. As far as I can remember the only thing I changed in this page (as it was working before) was the addition of the username and password parts.

Here are the other pages. This one is the first one, you click the submit button which takes you to the above script.

Code:
Code:
[TABLE] 
[TR][TD]Firstname:[/TD] [TD][/TD][/TR]
[TR][TD]Lastname:[/TD] [TD][/TD][/TR]
[TR][TD]Age: [/TD] [TD][/TD][/TR]
[TR][TD]Username: [/TD][TD][/TD][/TR]
[TR][TD]Password: [/TD][TD][/TD][/TR]
[TR][TD][/TD][/TR]
[/TABLE]
users.php

Code:
Code:
[CODE]
<?php
$con = mysql_connect("localhost","alpha_coll","college");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("alpha_coll", $con);

$result = mysql_query("SELECT * FROM Users");

echo "[TABLE]
[TR]
[TH]Firstname[/TH]
[TH]Lastname[/TH]
[TH]UserID[/TH]
[TH]Username[/TH]
[/TR]";

while($row = mysql_fetch_array($result))
  {
  echo "[TR]";
  echo "[TD]" . $row['FirstName'] . "[/TD]";
  echo "[TD]" . $row['LastName'] . "[/TD]";
  echo "[TD]" . $row['UserID'] . "[/TD]";
  echo "[TD]" . $row['Username'] . "[/TD]";
  echo "[/TR]";
  }
echo "[/TABLE]";

mysql_close($con);
?>

[URL=index.php?page=users]Add More Users[/URL]
[/CODE]
showusers.php
 

· Premium Member
Joined
·
14,563 Posts
You forgot a semicolon.
smile.gif


PHP:
mysql_close($con)
 
1 - 2 of 2 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top