Jump to content


Photo

Text Area Data into Mysql


  • Please log in to reply
25 replies to this topic

#21 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 04 September 2006 - 05:18 PM

As many other people have requested, and you have failed to do. Post the output of
echo $sql;
here.

#22 superhoops

superhoops
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts

Posted 04 September 2006 - 05:23 PM

As i said before the page goes blank when i submit the form, is that what you mean?

#23 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 04 September 2006 - 05:38 PM

So you get no outout what so ever. Looks like there is an error in there somewhere then. Tidied up the code a little. Try this:
<?php

error_reporting("E_ALL");

echo "connecting to MySQL";

$db = mysql_connect("username", "db", "password") or die("Could not connect.<br /><br />" . mysql_error());

echo "connected to mysql<br /><br />";

echo "Selecting database";

mysql_select_db("fmpsite_reg", $db) or die("No database selected.<br /><br />" . mysql_error());

echo "Database selected<br /><br />";

//if(!get_magic_quotes_gpc())
//    mysql_select_db("fmprotasy_reg", $con);
// NOT SURE ABOUT THE ABOVE SO I COMMENTED IT OUT;

echo "Attempting to insert data into database<br /><br />"

$Name = mysql_real_escape_string($_POST['Name']);
$Comment = mysql_real_escape_string($_POST['Comment']);

$sql = "INSERT INTO `Pre` SET `Name`='".$Name."', `Team`='".$_POST['Team']."', `Rating`='".$_POST['Rating']."', `Comment`='".$Comment."'";

echo "SQL OUTPUT:<br /><code>{$sql}</code><br /><br />";

mysql_query($sql) or die('Error: ' . mysql_error());

echo "Inserted data into database";

?>


#24 superhoops

superhoops
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts

Posted 04 September 2006 - 06:35 PM

I get this message with your code:

Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /home/www/fmprotasy.com/insertpre.php on line 23


#25 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 04 September 2006 - 06:47 PM

Add a semi-colon at the end of this line:
echo "Attempting to insert data into database<br /><br />"

It should be this
echo "Attempting to insert data into database<br /><br />";

#26 superhoops

superhoops
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts

Posted 05 September 2006 - 08:55 AM

Thank You very much, it works!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users