Re: PHP Form submitting to MySQL not working...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sorry I wasn't specific enough. I'll include the files.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd";>
<html>
<head>
<title>Prayer Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="css/prayer.css" rel="stylesheet" type="text/css">


<script type="text/javascript">

// specify the name of your form
var thisForm = "form1";

// load field names and default values into list
var defaultVals = new Array();
defaultVals[0] = new Array("date", "(Date here)");

// populate fields with default values on page load
function MPLoadDefaults() {
with (document.forms[thisForm]) {
for (var n=0; n<defaultVals.length; n++) {
var thisField = defaultVals[n][0];
var thisDefault = defaultVals[n][1];
if (elements[thisField].value == '')
elements[thisField].value = thisDefault;
}}}

// clear default value from field when selected
function MPClearField(field) {
var fieldName = field.name;
for (var n=0; n<defaultVals.length; n++) {
var thisField = defaultVals[n][0];
var thisDefault = defaultVals[n][1];
if (thisField == fieldName) {
if (field.value == thisDefault) field.value = '';
break;
}}}

// clear all defaults when form is submitted
function MPClearAll() {
with (document.forms[thisForm]) {
for (var n=0; n<defaultVals.length; n++) {
var thisField = defaultVals[n][0];
var thisDefault = defaultVals[n][1];
if (elements[thisField].value == thisDefault)
elements[thisField].value = '';
}}}

</script>

<style type="text/css">
<!--
body {
	font-family:Verdana, Arial, Helvetica, sans-serif, "Lucida Grande";
	font-size: 14px;
	line-height:18px;
	color: #333333;
	margin: 0 0 0 0;
	background-color: #CDCEDA;
	background-image: url(images/prayer_body_bg.jpg);
	background-position: center;
	background-repeat: repeat-y;
}
-->
</style></head>
<!-- <body OnLoad="document.form1.date.focus();"> -->
<!-- <body onload="MPLoadDefaults()"> -->
<body>
<form name="form1" method="post" action="db-code.php">
  <table width="100%" height="0"  border="0" cellpadding="0" cellspacing="0" bgcolor="#999999">
    <tr>
      <td><img src="spacer.gif" width="5" height="5"></td>
    </tr>
  </table>
  <table width="748" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td rowspan="2" valign="top" bgcolor="#CCCCCC"><table border="0" align="center" cellpadding="10" cellspacing="0">
        <tr>
          <td><!-- <input name="date" type="date" class="date_field" id="textfield" value="" size="30" onfocus="MPClearField(this)"> -->
		  <input name="date" type="date" class="date_field" id="textfield" value="<?php echo date('F j, Y'); ?>" size="30"> 
		  </td>
        </tr>
        <tr>
          <td class="prayer-field" valign="top"><textarea name="prayer" cols="60" rows="19" class="form_fields" id="prayer"></textarea></td>
        </tr>
        <tr>
          <td><input name="Reset" type="reset" class="NormalText" value="Reset">
            <input name="Submit2" type="submit" class="NormalText" value="Submit"></td>
        </tr>
        <tr>
          <td valign="top" bordercolor="#999999"><?php include "random_images.php"; ?>
            </td>
        </tr>
      </table>
</form>
</body>
</html>
<?PHP

	// log into our local server using the MySQL root user.
	$dbh = mysql_connect( "localhost", "*******", "********" );
	
	// select the db.
	mysql_select_db( "prayer" ) or die ( mysql_error() . "\n" );
	
	$date = $_POST["date"];
	$prayer = $_POST["prayer"];

//$prayer = nl2br ($prayer);
$prayer = addslashes ($prayer);
	
	$insert_data = "INSERT into prayer (view,date,prayer)
    Values ('view', '$date', '$prayer');";

    $response = mysql_query( $insert_data, $dbh );
	if(mysql_error()) die ('database error<br>'. mysql_error());
?>

<?PHP	
	
   // and read it back for printing purposes.
   //$get_table_data = "SELECT * FROM prayer WHERE date=\"$date\"";
   
   //$response = mysql_query( $get_table_data, $dbh );

   // now print it out for the user.
  // if ( $one_line_of_data = mysql_fetch_array( $response ) ) {
    //   extract ( $one_line_of_data );
  // }
   $id_num = mysql_insert_id();
   
 ?>
  <?PHP
	
//this is the update
		$update_data = "UPDATE prayer SET view = '<a href=\"view_prayer.php?id_num=$id_num\">view</a>' WHERE id_num = \"$id_num\"";
		
		$response = mysql_query( $update_data, $dbh );
	if(mysql_error()) die ('database error<br>'. mysql_error());
		
   // and read it back for printing purposes.
   $get_table_data = "SELECT * FROM prayer  where id_num=\"$id_num\";";
   
   $response = mysql_query( $get_table_data, $dbh );

   // now print it out for the user.
   if ( $one_line_of_data = mysql_fetch_array( $response ) ) {
       extract ( $one_line_of_data );
   }
	
?>

<html>
<head>
<title>Prayer for <?php echo "$date\n"; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<link href="css/prayer.css" rel="stylesheet" type="text/css">

<style type="text/css">
<!--
body {
	background-color: #EEEEEE;
	margin: 10px 0 0 0;
}
-->
</style></head>

<body>
<div id="mContent">
<?PHP

$prayer = nl2br ($prayer);
$prayer = stripslashes ($prayer);

echo "<div id = 'date'>$date<p /></div>";
echo "<div id ='prayer_space'>$prayer</div>";

$query = "SELECT view,date,prayer FROM prayer ORDER BY id_num DESC LIMIT 30";
$result = mysql_query($query) or die("Query failed");

echo "<div id='menu'>";

while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
	extract ( $line );
			$LimitChars = substr("$prayer", 0, 65);

echo "<div id='view_date' align='left'>$view - $date</div>";

}
echo "</div>";

?>
</div>
</body>
</html>

I downloaded and installed the iPhone SDK to develop some iPhone apps.
This form has worked forever. Perhaps the SDK install did something?

Thanks,

-- 
Steve Marquez
Marquez Design
e-mail: smarquez@xxxxxxxxxxxxxxxxxx
web: http://www.marquez-design.com
phone: 479-648-0325 

On Jun 3, 2010, at 8:59 AM, Ashley Sheridan wrote:

On Thu, 2010-06-03 at 08:56 -0500, Steve Marquez wrote:
Good morning,

I have a PHP form that I have been using for some time now on a Macbook Pro running PHP 5.3.1 and MySQL 5.0.5 and everything was working fine. But this morning, when I submitted (it is a journaling application) it came up with the following error: 

No such file or directory 

Can anyone point me in the right direction to fix this? Have you ever seen this before?

Thanks,

Steve Marquez

Do you have any examples of code at all? It sounds like a file it's requiring is missing, but you haven't given the full error there either.

Thanks,
Ash
http://www.ashleysheridan.co.uk




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux