insert from a textarea

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
markstamp
Forum Newbie
Posts: 3
Joined: Sun Dec 14, 2003 11:27 pm
Location: PA

insert from a textarea

Post by markstamp »

i am trying to get text from a TEXTAREA into a date base and i having some problems,
<?php
/*this page reciece and handles data generated by form.html*/

//set the variables
$Host = "******";
$User = "*******";
$Password = "****";
$DBName = "*****_****";
$TableName = "alumni";

$link = mysql_connect($Host, $User, $Password)
or die("Could not connect : " . mysql_error());
print "Connected successfully";
mysql_select_db("$DBName") or die("Could not select database");

mysql_connect("localhost","$User","$Password") or die ("Unable to connect to MySQL server.");
$db = mysql_select_db("$DBName") or die ("Unable to select requested database.");

$Link = mysql_connect($Host, $User, $Password);

$Query = "INSERT into $DBName.alumni (ritualnumber, class, firstname, lastname, address, city, state, zip, email, phone, comment, formal) values ('$ritualnumber', '$class', '$firstname', '$lastname', '$address', '$city', '$state', '$zip', '$email', '$phone', '$comment', '$formal')";

$Query = "Select * from $DBName.alumni order by LastName";
Print("the query is :<br>$Query<p>\n");
if (mysql_db_query ($DBName, $Query, $Link)){
print ("the query has been executed<br>\n");
} else {
print ("the query sucks redo it<br>\n");
}

$Result = mysql_db_query($DBName, $Query, $Link);
// create table
print ("<Table Border = 1 width=\"75%\" cellspacing =2 cellpadding=2 align=center>\n");
print ("<TR align=center valign=top>\n");
print ("<TD align=center valign=top>Ritual Number</TD>\n");
print ("<TD align=center valign=top>Class</TD>\n");
print ("<TD align=center valign=top>First Name</TD>\n");
print ("<TD align=center valign=top>Last Name</TD>\n");
print ("<TD align=center valign=top>Address</TD>\n");
print ("<TD align=center valign=top>City</TD>\n");
print ("<TD align=center valign=top>State</TD>\n");
print ("<TD align=center valign=top>Zip</TD>\n");
print ("<TD align=center valign=top>Email</TD>\n");
print ("<TD align=center valign=top>Phone</TD>\n");
print ("<TD align=center valign=top>Comments</TD>\n");
print ("<TD align=center valign=top>Formal</TD>\n");
print ("</TR>\n");
//fetch results
while ($Row = mysql_fetch_array($Result)){
print ("<TR Align=center valign=top>\n");
print ("<TD Align=center valign=top>$Row[ritualnumber]</TD>\n");
print ("<TD Align=center valign=top>$Row[class]</TD>\n");
print ("<TD Align=center valign=top>$Row[firstname]</TD>\n");
print ("<TD Align=center valign=top>$Row[lastname]</TD>\n");
print ("<TD Align=center valign=top>$Row[address]</TD>\n");
print ("<TD Align=center valign=top>$Row[city]</TD>\n");
print ("<TD Align=center valign=top>$Row[state]</TD>\n");
print ("<TD Align=center valign=top>$Row[zip]</TD>\n");
print ("<TD Align=center valign=top>$Row[email]</TD>\n");
print ("<TD Align=center valign=top>$Row[phone]</TD>\n");
print ("<TD Align=center valign=top>$Row[comment]</TD>\n");
print ("<TD Align=center valign=top>$Row[formal]</TD>\n");
print ("</TR>\n");
}
print ("</Table>\n");

mysql_close ($Link);

?>
anyone know why this is working all the fields but comments are working???
markstamp
Forum Newbie
Posts: 3
Joined: Sun Dec 14, 2003 11:27 pm
Location: PA

Post by markstamp »

well now none of them work damn it whats wrong
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

If you manually enter in a record into your table, when you go to output the records using php, do they get displayed?
User avatar
aquila125
Forum Commoner
Posts: 96
Joined: Tue Dec 09, 2003 10:39 am
Location: Belgium

Post by aquila125 »

put all the columnnames in $row between quotes.. (won't fix your problem, but is a good habit to do so)
Post Reply