对于所有这些 php 函数,我都为 null:
echo gettype($row);
echo gettype($foo);
echo gettype($foo1);
echo gettype($oldstring);
echo gettype($oldstring2);
echo gettype($changedstring);
echo gettype($changedstring2);
当我没有进行所有查询时,代码就起作用了,我只是将它用作输入值的表单。除了现在,我需要在我的表单中使用 php 来显示某些值。
我还仔细检查了相应列下的数据库,它们确实具有正确和完整的值。查询确实在不同的页面上工作,但在此页面上显示为 null。
这是代码:
<?php
session_start();
if($_POST['formSubmit'] == "Submit")
{
$errorMessage="";
if (empty($_POST['camperpickedup']))
{
$errorMessage .="<li>You forgot to select whether the camper is being picked up!</li>";
}
if (empty($_POST['personPickingUpCamper']))
{
$errorMessage ="<li>You forgot to enter the person picking up the camper!</li>";
}
$_SESSION['camperpickedup'] = $_POST['camperpickedup'];
$_SESSION['personPickingUpCamper'] = $_POST['personPickingUpCamper'];
$db = mysql_connect(
':/Applications/MAMP/tmp/mysql/mysql.sock',
'root',
'root'
);
if(!$db) die("Error connecting to MySQL database.");
mysql_select_db('onlineform', $db);
$query = mysql_query("SELECT newPrice,numberOfWeeks FROM onlineformdata ORDER BY id DESC LIMIT 1");
$row = mysql_fetch_row($query);
$query1 = mysql_query("SELECT newCampSessions FROM onlineformdata ORDER BY id DESC LIMIT 1") or die('Error ' . mysql_error());
$foo = mysql_fetch_array($query1);
$query2 = mysql_query("SELECT pricePerWeek FROM onlineformdata ORDER BY id DESC LIMIT 1") or die('Error ' . mysql_error());
$foo1 = mysql_fetch_array($query2);
$oldstring = $foo['newCampSessions'];
$oldstring2 = $foo1['pricePerWeek'];
$changedstring = unserialize($oldstring);
$changedstring2 = unserialize($oldstring2);
}
?>
<!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>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.7.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.10/jquery-ui.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<link type="text/css" rel="stylesheet" href="stylesheet.css"/>
<link href='http://fonts.googleapis.com/css?family=Alef' rel='stylesheet' type='text/css'>
<link type="text/css" rel="stylesheet" href="style3.css"/>
<script type="text/javascript" src="JavaScript.js">
</script>
<script type="text/javascript">var jslang='EN';
</script>
<link href="http://activemindandbody.orgStyleSheets/ModuleStyleSheets.css" rel="StyleSheet" type="text/css" />
<script type="text/javascript">var jslang='EN';
</script>
<link href="http://activemindandbody.org/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/modernizr.custom.04022.js"></script>
<link href='http://fonts.googleapis.com/css?family=Open+Sans+Condensed:700,300,300italic' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Alef' rel='stylesheet' type='text/css'>
</head>
<body>
<!-- BC_OBNW -->
<div id="container">
<div id="header"><div id="header_text" style="top: 118px; left: 23px;">
<p>Make a donation today and help âCreating a Brighter Future
Together.â <a href="http://activemindandbody.org/donation.html">Make a donation now !</a> </p>
</div>
</div>
<div id="content">
<section class="tabs">
<input id="tab-1" type="radio" name="radio-set" class="tab-selector-1" checked="checked" />
<label for="tab-1" class="tab-label-1">1. Camper's Info</label>
<input id="tab-2" type="radio" name="radio-set" class="tab-selector-2" />
<label for="tab-2" class="tab-label-2">2. Parent's Info</label>
<input id="tab-3" type="radio" name="radio-set" class="tab-selector-3" />
<label for="tab-3" class="tab-label-3">3. Emergency<br/> Contacts</label>
<input id="tab-4" type="radio" name="radio-set" class="tab-selector-4" />
<label for="tab-4" class="tab-label-4">4. Camper's Ride Home</label>
<input id="tab-5" type="radio" name="radio-set" class="tab-selector-5" />
<label for="tab-5" class="tab-label-5">5. <br/> Camp Days & Prices</label>
<input id="tab-6" type="radio" name="radio-set" class="tab-selector-6" />
<label for="tab-6" class="tab-label-6">6. Confirm your details</label>
<input id="tab-7" type="radio" name="radio-set" class="tab-selector-7" />
<label for="tab-7" class="tab-label-7">7. <br />Paypal</label>
</section>
<div class="clear-shadow"></div>
<div class="content indent">
<form id="paymentform" action="amd8.php" method="post">
<br />
<label><b>Camp Sessions: 1-6 (Check off the week(s) the camper will be participating in.)</b> </label><br /><br />
<ol>
<?php
for ($count = 0; $count < $row[1]; $count++)
{
echo"<li>"; echo $changedstring[$count]; echo '($'; echo $changedstring2[$count]; echo '/child)<input type=checkbox name="campsessions[]" value="'; echo $changedstring[$count]; echo "></li>;";
}
echo gettype($row);
echo gettype($foo);
echo gettype($foo1);
echo gettype($oldstring);
echo gettype($oldstring2);
echo gettype($changedstring);
echo gettype($changedstring2);
?>
<li>July 8 - July 12 ($75/child)<input type=checkbox name="campsessions[]" value="July8-July12" onclick="getTotal()" id="includeweek1"></li>
<li>July 15 - July 19 ($75/child)<input type=checkbox name="campsessions[]" value="July15-July19" onclick="getTotal()" id="includeweek2"></li>
<li>July 22 - July 26 ($75/child)<input type=checkbox name="campsessions[]" value="July22-July26" onclick="getTotal()" id="includeweek3"></li>
<li>July 29 - August 2 ($75/child)<input type=checkbox name="campsessions[]" value="July29-August2" onclick="getTotal()" id="includeweek4"></li>
<li>August 6 - August 9 ($60/child)<input type=checkbox name="campsessions[]" value="August6-August9" onclick="getTotal()" id="includeweek5"></li>
<li>August 12 - August 16 ($75/child)<input type=checkbox name="campsessions[]" value="August12-August16" onclick="getTotal()" id="includeweek6"></li>
</ol>
<label> <b> Include After Camp Care? </b></label> <input type="checkbox" name= "campcare" onclick="getTotal()" id="aftercampcare" /> <br /><br />
<i> After Camp Care is available from 4pm-6pm for an additional charge of $2/hr.</i><br /><br />
Total Price: $<span class="totalPrice"> </span>
<br/><br/>
<input type="hidden" name="totalprice" />
<input type="submit" name="formSubmit" value="Submit" class="button greenButton"/>
<input type="button" name="cancel" value="Cancel" class="button redButton" onclick="href='activemindandbody.org'">
</form>
</div>
</div>
</body>
</html>