Lost Password?


Go Back   CodeCall Programming Forum > Web Development Forum > Database & Database Programming

Database & Database Programming MySQL, Oracle, SQL, PL/SQL, ABAP, Smart Forms, and other databases and languages. A database is an organized body of related information used in many websites (including CC).

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-21-2007, 02:04 AM
thesquirrel16 thesquirrel16 is offline
Newbie
 
Join Date: Apr 2007
Posts: 12
Rep Power: 0
thesquirrel16 is on a distinguished road
Default Help! Can't get values into database

Hi, okay so I am new to databasing but I have been following some tutorials to try to get started, I have a database created with a table. Here is the code I am using to try to input the values into the table.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<p>The Official try at this ****</p>
<input type="submit" />
<?php
$con = mysql_connect(server , username, pw);

if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("eventdb", $con);

mysql_query("INSERT INTO title (Title, Host, Place)
VALUES ('Peter', 'Griffin', '35')");
mysql_close($con);
?>
<p>&nbsp;</p>
</body>
</html>



The username/pw/server is all correct it connects fine, but the values are not inserted into the table for some reason. I have tried upper case and lower case just to try on the collumns. The database is called eventdb and the table is called title and the columns are called Title, Host, Place. Any idea why this code isn't working? I am building in DreamWeaver. Also... another side question, when does the page know when to run the php? when it loads?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 04-21-2007, 03:21 AM
v0id's Avatar   
v0id v0id is online now
Retired
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,635
Last Blog:
CherryPy(thon)
Rep Power: 28
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default

Try using the [ code ]-tags.

Try to do this;
Code:
mysql_query("INSERT INTO title (Title, Host, Place) VALUES ('Peter', 'Griffin', '35')") or die(mysql_error());
Then you can see if some errors occurs.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-21-2007, 04:45 AM
thesquirrel16 thesquirrel16 is offline
Newbie
 
Join Date: Apr 2007
Posts: 12
Rep Power: 0
thesquirrel16 is on a distinguished road
Default re

Hi, thanks for the reply, I added that line in and nothing happened still. I am going to guess that either the php code isn't running or the error isn't outputting. Any idea which it would be? How does the form know to call to the php code when the button is clicked?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-21-2007, 07:18 AM
thesquirrel16 thesquirrel16 is offline
Newbie
 
Join Date: Apr 2007
Posts: 12
Rep Power: 0
thesquirrel16 is on a distinguished road
Default

Ok, I think i have another theory on why this isn't working. I am running all of that code in an html file, does it need to be a php file? Or do I need one of each? Is there a good tutorial about this?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-21-2007, 08:09 AM
v0id's Avatar   
v0id v0id is online now
Retired
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,635
Last Blog:
CherryPy(thon)
Rep Power: 28
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default

Hehe, that's your problem.
When your putting them in a HTML-file, the browser thinks the <?php is a tag, and the same with ?>. If you try, you can the the source online, if it's in a HTML-file. You can't do that if it's a PHP-file, because it executes at the server, not trough the browser.

Try to replace your extension ".htm" or ".html" with ".php", then it should work.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 04-21-2007, 06:13 PM
thesquirrel16 thesquirrel16 is offline
Newbie
 
Join Date: Apr 2007
Posts: 12
Rep Power: 0
thesquirrel16 is on a distinguished road
Default

lol yep that was it, im an idiot, thanks a bunch (<-- newb) =)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieving Access Database tigger Visual Basic Programming 0 07-06-2007 01:27 AM
Best program for SQL database manipulation Rhadamanthys Database & Database Programming 3 07-02-2007 03:32 PM
Best way to save lots of small values (in a database)? Vantage General Programming 2 05-14-2007 08:57 AM
Small job - Database extraction - Delphi 7 of compliant paul. Request Services (Paid) 4 04-11-2007 12:41 PM
Sudoku can be solved using SQL..Take a look! roger Database & Database Programming 5 07-04-2006 03:20 PM


All times are GMT -5. The time now is 12:09 PM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 98%

Ads