Jump to content

writing into mysql


rilana

Recommended Posts

Hi everyone. I am trying to figure out something supposely easy and I cant get it working. Please help me. I do have a flash form and I am sending data via a php to an e-mail Adress. So far so good. That works. But now I am trying to write the info into a mysql database at the same time. I tryed setting it up with a html form and php to start. But I cant evan get that to work! My hosting Package only support PHP 5. Maby thats the Problme. But I dont have a clue. Please help. I realy would aprechiate to find out what I am doing wrong.

 

This is my html

<!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=UTF-8" />
<title>Unbenanntes Dokument</title>
</head>

<body>

<html>
<body>

<form action="form.php" method="post">
from: <input type="text" name="from" />
Geschlecht: <input type="text" name="Geschlecht" />
Vorname: <input type="text" name="Vorname" />
Name: <input type="text" name="Name" />
Loesung: <input type="text" name="Loesung" />
Fahrzeug: <input type="text" name="Fahrzeug" />
Teilnahmebedingung: <input type="text" name="Teilnahmebedingung" />
<input type="submit" />
</form>


</body>
</html>
</body>
</html>

 

And this my PHP

          
<?php
$link = mysql_connect('rilanab.mysql.db.internal', 'rilanab_rilana', 'rilana');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
mysql_select_db('rilanab_form');


mysql_query("INSERT INTO person (from, Geschlecht, Vorname, Name, Loesung, Fahrzeug, Teilnahmebedingung)
          VALUES('$from', '$Geschlecht', '$Vorname', $Name', $Loesung', $Fahrzeug', $Teilnahmebedingung')");

?>

          

The connection to the database seems to be working.

 

And this my database dump

-- phpMyAdmin SQL Dump
-- version 2.11.4
-- http://www.phpmyadmin.net
--
-- Host: mysql02.db.hostpoint.internal
-- Erstellungszeit: 29. Februar 2008 um 14:25
-- Server Version: 5.1.22
-- PHP-Version: 5.2.5

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Datenbank: `rilanab_form`
--

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `personnel`
--

CREATE TABLE IF NOT EXISTS `personnel` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `Vorname` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL,
  `Name` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
  `Geschlecht` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL,
  `from` varchar(35) COLLATE utf8_unicode_ci DEFAULT NULL,
  `Loesung` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
  `Fahrzeug` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
  `Teilnahmebedingung` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
  UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

--
-- Daten für Tabelle `personnel`
--

 

Please help. Thanks a lot!

Link to comment
https://forums.phpfreaks.com/topic/93679-writing-into-mysql/
Share on other sites

yes I saw that mistake earlier, but it still want work...  I evan found a easier tutorial which also doesnt work....

<?php
//connecting
$dbname = "";
$dbloc = "";
$dbuser = "";
$dbpass = "";
mysql_connect($dbloc, $dbuser, $dbpass) or die (mysql_error());
mysql_select_db($dbname) or die (mysql_error());
//end connecting
$name = strip_tags($http_post_data['name2']);
$msg = strip_tags($http_post_data['msg']);
$insert_str  = "INSERT INTO flashnphp(name, msg) VALUES('" . $name . "', '" . $msg . "')";
$mysql = mysql_query($insert_str);
if($mysql){
echo "done";
}
else
{
echo "error :" . mysql_error();
}
?>

 

this one does create rows in the table, but only empty once. I checked all the spelling and it's all correct.

 

Thanks for helping I realy aprechiate it!

Link to comment
https://forums.phpfreaks.com/topic/93679-writing-into-mysql/#findComment-480461
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.