| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| Account Closed | PHP code not working Code: $connection = mysql_connect("localhost", "$user", "$password") or die("Couldn't connect to database");
$db = mysql_select_db($database, $connection) or die("Couldn't choose database.");
$sql = mysql_query("INSERT INTO $table_name (first_name, last_name, birthdate, address, city, state, zip, phone) VALUES ('$first_name', '$last_name', '$birthdate', '$address', '$city', '$state', '$zip', '$phone')");
can someone tell me why the above code isn't putting anything inat a database except the int and date defaults? |
| |
| | #4 (permalink) |
| Account Closed | not sure but if you are getting this info from a form posting with method of POST or GET: PHP Code: if your using the GET method change _POST to _GET. Cody Selzer |
| |
| | #8 (permalink) |
| Account Closed | Code: <?php
$db_name = "xxxxxxx";
$username = "xxxxxx";
$password = "xxxxxx";
$tbl_name = "xxxxxx";
$connection = mysql_connect("localhost", "$username", "$password") or die("Couldn't connect to database");
$db = mysql_select_db($db_name, $connection) or die("Couldn't choose database.");
$sql = mysql_query("INSERT INTO $tbl_name (first_name, last_name, birthdate, address, city, state, zip, phone) VALUES ('$first_name', '$last_name', '$birthdate', '$address', '$city', '$state', '$zip', '$phone')");
mysql_query($sql);
$result = mysql_query($sql, $connection);
if (!$result) {
die('Could not query:' . mysql_error());
}
else {
die('Data entered correctly.');
}
?>
<html>
<title>Database connect</title>
<body>
<?
echo "$msg";
echo "<p>First Name: $first_name <br>";
echo "<p>Last Name: $last_name <br>";
echo "<p>Birthdate: $birthdate <br>";
echo "<p>Address: $address <br>";
echo "<p>City: $city <br>";
echo "<p>State: $state <br>";
echo "<p>Zip: $zip <br>";
echo "<p>Phone: $phone <br>";
?>
</body>
</html>
There's the whole code still not working |
| |
| | #9 (permalink) |
| Account Closed | odd, wheres the form? PHP Code: |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Tutorial: Getting started with PHP (The Basics) | deadserious | Webmaster Tutorials | 60 | 11-17-2007 11:35 AM |
| Googlism - What does google think of you? | deadserious | The Break Room | 55 | 12-15-2005 09:09 AM |
| Basic HTML Tutorial | webgear | Webmaster Tutorials | 8 | 04-02-2005 02:20 PM |