我如何定义$ Row?

时间:2016-08-12 03:19:20

标签: php

我正在学习PHP。我有大约167行代码,类似于下面。其中的每个人都为Row Undefined返回错误。我知道我必须定义它,但我如何在我的例子中这样做?

我有一个调用另一个文件的页面:我按如下方式编写了查询:

 <?php 
include ("../../incl/gameconn.php"); 
 ?>
 <?php
echo $_POST["char_name"]."<br>";

 $result = mysqli_query($con, "SELECT * FROM `topdata` a, `abilities` b,      `attributes` c, `backgrounds` d, `basics` e, `combat` f, `disciplines` g, `extras` h, `fetish` i, `gifts` j, `homes` k, `influence` l, `lores` m, `meritflaw` n, `rituals` o, `seconds` p, `spheres` q, `virtues` r, `wonders` s, `accounts` t WHERE (a.char_name=b.char_name) AND (b.char_name=c.char_name) AND (c.char_name=d.char_name) AND (d.char_name=e.char_name) AND (e.char_name=f.char_name) AND (f.char_name=g.char_name) AND (g.char_name=h.char_name) AND (h.char_name=i.char_name) AND (i.char_name=j.char_name) AND (j.char_name=k.char_name) AND (k.char_name=l.char_name) AND (l.char_name=m.char_name) AND (m.char_name=n.char_name) AND (n.char_name=o.char_name) AND (o.char_name=p.char_name) AND (p.char_name=q.char_name) AND (q.char_name=r.char_name) AND (r.char_name=s.char_name) AND (s.char_name=t.log_name) AND (a.char_name=\"$_POST[char_name]\")");

include ("calls.php");  /* This MUST stay here or we lose the sheets!!  Do not move it!  */

   while ($row = mysqli_fetch_assoc($result))
   {
    if ($row['sub_venue'] == 'Mortal')
    { include ('mortal.php'); }
    elseif ($row['sub_venue'] == 'Vampire')
    { include('vampire.php'); }
    elseif ($row['sub_venue'] == 'Ghoul')
    { include('ghoul.php'); }
    elseif ($row['sub_venue'] == 'Werewolf')
    { include('werewolf.php'); }
    elseif ($row['sub_venue'] == 'Kinfolk')
    { include('kinfolk.php'); }
    elseif ($row['sub_venue'] == 'Mage')
    { include('mage.php'); }
    elseif ($row['sub_venue'] == 'Sorcerer')
    { include('sorcerer.php'); }
    else echo "<p>We seem to be having a probem pulling up sheets...<br />Savvannis is probably pulling her hair at right now trying to figure out why the code isn't working properly.<br/>Thank you for your patience, we are amazed that anyone still has any!</p>";
   }

 ?>

以下是我的查询所依赖的php文件/代码,并依赖于

$charname=$row['char_name'];$logname=$_SESSION['whoiam'];$accttype=$row['account_type'];
$owner=$row['owner'];$venue=$row['char_venue'];$subvenue=$row['sub_venue'];
$species=$row['species'];$gender=$row['gender'];$age=$row['age'];$appage=$row['appage'];
$nature=($row['nature']);$demeanor=($row['demeanor']);$concept=($row['concept']);
$descript=($row['description']);$web_site=($row['web_site']);$viewpw=$row['viewpw'];
$sfa=$row['sfa'];$acting=$row['acting'];$alertness=$row['alertness'];
$athletics=$row['athletics'];$brawl=$row['brawl'];$dodge=$row['dodge'];
$empathy=$row['empathy'];$expression=$row['expression'];$intimidation=$row['intimidation'];
$leadership=$row['leadership'];$streetwise=$row['streetwise'];$subterfuge=$row['subterfuge'];
$animalken=$row['animalken'];$crafts=$row['crafts'];$drive=$row['drive'];
$etiquette=$row['etiquette'];$firearms=$row['firearms'];$melee=$row['melee'];
$music=$row['music'];$performance=$row['performance'];$security=$row['security'];
$stealth=$row['stealth'];$survival=$row['survival'];$academics=$row['academics'];
$computer=$row['computer'];$finance=$row['finance'];$investigation=$row['investigation'];
$law=$row['law'];$linguistics=$row['linguistics'];$medicine=$row['medicine'];
$occult=$row['occult'];$politics=$row['politics'];$science=$row['science'];
$intuition=$row['intuition'];$repair=$row['repair'];$primalurge=$row['primalurge'];
$enigmas=$row['rituals'];$cosmology=$row['cosmology'];$meditation=$row['meditation'];
$enigmas=$row['enigmas'];$technology=$row['technology'];abilspec=$row['abilspecial'];
$aware=$row['awareness'];$burea=$row['bureaucracy'];

1 个答案:

答案 0 :(得分:0)

<?php 
include ("../../incl/gameconn.php");
include ("calls.php");  /* This MUST stay here or we lose the sheets!!  Do not move it!  */

echo $_POST['char_name'], '<br>';

$result = mysqli_query($con, "
  SELECT sub_venue ## which sub_venue ? a.sub_venue ?
  FROM topdata     AS a
  JOIN abilities   AS b ON a.char_name = b.char_name
  JOIN attributes  AS c ON b.char_name = c.char_name
  JOIN backgrounds AS d ON c.char_name = d.char_name
  JOIN basics      AS e ON d.char_name = e.char_name
  JOIN combat      AS f ON e.char_name = f.char_name
  JOIN disciplines AS g ON f.char_name = g.char_name
  JOIN extras      AS h ON g.char_name = h.char_name
  JOIN fetish      AS i ON h.char_name = i.char_name
  JOIN gifts       AS j ON i.char_name = j.char_name
  JOIN homes       AS k ON j.char_name = k.char_name
  JOIN influence   AS l ON k.char_name = l.char_name
  JOIN lores       AS m ON l.char_name = m.char_name
  JOIN meritflaw   AS n ON m.char_name = n.char_name
  JOIN rituals     AS o ON n.char_name = o.char_name
  JOIN seconds     AS p ON o.char_name = p.char_name
  JOIN spheres     AS q ON p.char_name = q.char_name
  JOIN virtues     AS r ON q.char_name = r.char_name
  JOIN wonders     AS s ON r.char_name = s.char_name
  JOIN accounts    AS t ON s.char_name = t.char_name
  WHERE a.char_name ='". $_POST['char_name'] ."')");

$inc = array();
$files = array('Mortal', 'Vampire', 'Ghoul', 'Werewolf', 'Kinfolk', 'Mage', 'Sorcerer');
while ($row = mysqli_fetch_assoc($result)) {
    if (in_array($row['sub_venue'], $files)) {
        $inc[$row['sub_venue']] = 1;
    }
}
foreach ($inc as $i) {
    include strtolower($i) .'.php';
}
if (!$inc) {
    echo '<p>We seem to be having a probem pulling up sheets...<br>Savvannis is probably pulling her hair at right now trying to figure out why the code isn\'t working properly.<br>Thank you for your patience, we are amazed that anyone still has any!</p>';
}