Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › T_String Error that I cannot spot
New Posts  All Forums:Forum Nav:

T_String Error that I cannot spot

post #1 of 2
Thread Starter 
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");

?>
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:
<form action="index.php?page=adduser" method="post">
<table rows="7"cols="2"> 
<tr><td>Firstname:</td> <td><input type="text" name="firstname" /></td></tr>
<tr><td>Lastname:</td> <td><input type="text" name="lastname" /></td></tr>
<tr><td>Age: </td> <td><input type="text" name="age" /></td></tr>
<tr><td>Username: </td><td><input type="text" name="username" /></td></tr>
<tr><td>Password: </td><td><input type="text" name="password" /></td></tr>
<tr><td><input type="submit" /></td></tr>
</table>
</form>
users.php

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 border='1'>
<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);
?> 

<a href="index.php?page=users">Add More Users</a>
showusers.php
    
CPUMotherboardGraphicsRAM
Intel i5 2500 @ 4,004GHz (1.202v) Asus P8P67-PRO B3 Leadtek GTX260 65nm 896MB 700|1430|1100 4GB DDR3 Muskin 1686MHz 
Hard DriveOptical DriveOSMonitor
2xWD CB 250GB, 2x SG 320GB, 1xSS F1 1TB Pioneer DVD-RW Windows 7 Professional 64bit Samsung 2032BW 20" 1680x1050 16:10 
KeyboardPowerCaseMouse
Razer Lycosa CoolerMaster GX 550W Coolermaster Storm Sniper Razer DeathAdder 
Mouse Pad
Razer Goliathus 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Intel i5 2500 @ 4,004GHz (1.202v) Asus P8P67-PRO B3 Leadtek GTX260 65nm 896MB 700|1430|1100 4GB DDR3 Muskin 1686MHz 
Hard DriveOptical DriveOSMonitor
2xWD CB 250GB, 2x SG 320GB, 1xSS F1 1TB Pioneer DVD-RW Windows 7 Professional 64bit Samsung 2032BW 20" 1680x1050 16:10 
KeyboardPowerCaseMouse
Razer Lycosa CoolerMaster GX 550W Coolermaster Storm Sniper Razer DeathAdder 
Mouse Pad
Razer Goliathus 
  hide details  
Reply
post #2 of 2
You forgot a semicolon.

Code:

mysql_close($con) 

Underground
(14 items)
 
  
CPUMotherboardGraphicsRAM
Core i7 920 C0 ASUS P6T6 WS Revolution GTX 460 TR3X6G1600C8D 
Hard DriveOptical DriveCoolingOS
WD1001FALS SAMSUNG SH-S223F 22X DVD MULTI Corsair H50 Fedora 16 KDE x86_64 
MonitorKeyboardPowerCase
HP w19b Microsoft Comfort Curve Corsair CX600 Thermaltake Armor VA8003BWS 
MouseMouse Pad
Razer DeathAdder Black 
  hide details  
Reply
Underground
(14 items)
 
  
CPUMotherboardGraphicsRAM
Core i7 920 C0 ASUS P6T6 WS Revolution GTX 460 TR3X6G1600C8D 
Hard DriveOptical DriveCoolingOS
WD1001FALS SAMSUNG SH-S223F 22X DVD MULTI Corsair H50 Fedora 16 KDE x86_64 
MonitorKeyboardPowerCase
HP w19b Microsoft Comfort Curve Corsair CX600 Thermaltake Armor VA8003BWS 
MouseMouse Pad
Razer DeathAdder Black 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Web Coding
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › T_String Error that I cannot spot