Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php sql查询在回显时返回空值_Php_Html_Sql_Forms_Null - Fatal编程技术网

Php sql查询在回显时返回空值

Php sql查询在回显时返回空值,php,html,sql,forms,null,Php,Html,Sql,Forms,Null,所有这些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:

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&nbsp;&nbsp;âCreating a Brighter Future                      
    Together.â&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; <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>

无标题文件
var jslang='EN';
var jslang='EN';
今天捐款,帮助创造更美好的未来
一起,一起

1.露营者信息 2.家长信息 3.紧急联系人 4.露营车回家 5.
露营日和价格 6.确认您的详细信息 7.
贝宝
夏令营课程:1-6(勾选露营者将参加的一周。

  • 7月8日至7月12日(75美元/儿童)
  • 7月15日至7月19日(75美元/儿童)
  • 7月22日至7月26日(75美元/儿童)
  • 7月29日至8月2日(75美元/儿童)
  • 8月6日至8月9日(60美元/儿童)
  • 8月12日至8月16日(75美元/儿童)
  • 包括露营后护理

    夏令营结束后的护理时间为下午4点至6点,每小时额外收费2美元。

    总价:$


    您的MySQL逻辑被封装在一个布尔检查表单$\u POST['formSubmit']中,该表单失败

    第一步。这将出现在php文档的顶部。ini设置(“显示错误”,1);是的,我试过了,回显时除了数字1没有显示任何内容。不,你不回显这个。(!)注意:未定义的索引:formSubmit in/Applications/MAMP/htdocs/website/amd7.php第4行调用Stack#Time Memory Function Location 1 0.0052 241240{main}()../amd7.php:0BAMF。问题解决了。您的整个sql逻辑被封装在一个失败的布尔检查中。实际上,我关闭了if语句,所以它不会影响查询。但是,它仍然给了我同样的问题。嗯,你所做的就是在我连接到数据库之前,把括号向下移动,对吗?如果它确实对您有效,我的foreach循环是否正确工作?