0

我正在使用 php 脚本,是的,我知道它使用过时的 mysql 编码。我计划在不久的将来更新网站上的编码,但是我上传的图像有问题,我似乎无法排序。当我构建脚本时它工作得很好,现在它只是停止工作了。我已经多次扫描编码,但找不到错误。我确定我只是在看它,但也许不是?

输入代码:

include 'db_connect4.php';

mysql_select_db("db#########", $con);

echo "<h2 style='margin-top:5px; margin-bottom: 20px;'>Home Page</h2>";

if($nt == "upd"){
    echo "<font style='color: #f00; float: right;'>SITE UPDATED<br />$date $time</font>";
}
elseif($nt == "cnl"){
    echo "<font style='color: #f00; float: right;'>CHANGES CANCELED<br />$date $time</font>";
}
else{}

$result = mysql_query("SELECT * FROM page_info WHERE nm='title' && loc='Home'");
while($row = mysql_fetch_array($result)){ echo "<p style='margin-left:25px;'><b>Page Title</b> <br /><input type='text' name='title' value='$row[3]' style='margin-left: 20px;'></p>"; }

$result = mysql_query("SELECT * FROM page_info WHERE nm='welcome' && loc='Home'");
while($row = mysql_fetch_array($result)){ echo "<p style='margin-left:25px;'><b>Welcome Paragraph Title</b> <br /><input type='text' name='welcome' value='$row[3]' size='50' style='margin-left: 20px;'></p>"; }

$result = mysql_query("SELECT * FROM page_info WHERE nm='welcome_message' && loc='Home'");
while($row = mysql_fetch_array($result)){ echo "<font style='margin-left:25px;'><b>Welcome Paragraph</b></font>
    <div style='margin-left: 45px;'>
        <textarea id='textarea1' name='welcome_message' style='height: 250px; width: 600px;'>
               $row[3]
        </textarea></div>"; }

$result = mysql_query("SELECT * FROM page_info WHERE nm='services' && loc='Home'");
while($row = mysql_fetch_array($result)){ echo "<p style='margin-left:25px;'><b>Services List Title</b> <br /><input type='text' name='services' value='$row[3]' size='50' style='margin-left: 20px;'></p>"; }

$result = mysql_query("SELECT * FROM page_info WHERE nm='services_list' && loc='Home'");
echo "<p style='margin-left:25px;'><b>Services List</b> ";
while($row = mysql_fetch_array($result)){ echo "<br /><input type='text' name='services_list_$row[0]' value='$row[3]' size='30' style='margin-left: 20px;'>"; }
echo "</p>";

$result = mysql_query("SELECT * FROM page_info WHERE nm='service' && loc='Home'");
while($row = mysql_fetch_array($result)){ echo "<p style='margin-left:25px;'><b>Services Photo Section Title</b> <br /><input type='text' name='service' value='$row[3]' size='50' style='margin-left: 20px;'></p>"; }

echo "<table width='100%' border='0'>";
    echo "<tr>";
        $result = mysql_query("SELECT * FROM image_info WHERE nm='serv1' && loc='Home'");
        while($row = mysql_fetch_array($result)){  echo "<td align='center'><img src='$row[3]' height='$row[4]px' width='$row[5]px'><br /><input type='file' name='serv1'></td>"; }
        $result = mysql_query("SELECT * FROM image_info WHERE nm='serv2' && loc='Home'");
        while($row = mysql_fetch_array($result)){  echo "<td align='center'><img src='$row[3]' height='$row[4]px' width='$row[5]px'><br /><input type='file' name='serv2'></td>"; }
        $result = mysql_query("SELECT * FROM image_info WHERE nm='serv3' && loc='Home'");
        while($row = mysql_fetch_array($result)){  echo "<td align='center'><img src='$row[3]' height='$row[4]px' width='$row[5]px'><br /><input type='file' name='serv3'></td>"; }
    echo "</tr><tr>";
        $result = mysql_query("SELECT * FROM page_info WHERE nm='serv1b' && loc='Home'");
        while($row = mysql_fetch_array($result)){  echo "<td align='center'><textarea name='serv1b' cols='50' rows='5'>$row[3]</textarea></td>"; }
        $result = mysql_query("SELECT * FROM page_info WHERE nm='serv2b' && loc='Home'");
        while($row = mysql_fetch_array($result)){  echo "<td align='center'><textarea name='serv2b' cols='50' rows='5'>$row[3]</textarea></td>"; }
        $result = mysql_query("SELECT * FROM page_info WHERE nm='serv3b' && loc='Home'");
        while($row = mysql_fetch_array($result)){  echo "<td align='center'><textarea name='serv3b' cols='50' rows='5'>$row[3]</textarea></td>"; }
    echo "</tr>";
echo "</table>";

$result = mysql_query("SELECT * FROM page_info WHERE nm='news' && loc='Home'");
while($row = mysql_fetch_array($result)){ echo "<p style='margin-left:25px;'><b>Company News Title</b> <br /><input type='text' name='news' value='$row[3]' size='50' style='margin-left: 20px;'></p>"; }

$result = mysql_query("SELECT * FROM page_info WHERE nm='testimonials' && loc='Home'");
while($row = mysql_fetch_array($result)){ echo "<p style='margin-left:25px;'><b>Testimonials Title</b> <br /><input type='text' name='testimonials' value='$row[3]' size='50' style='margin-left: 20px;'></p>"; }

echo "<hr style='width: 100%; height: 5px; background: #000; margin-top: 20px; margin-bottom: 20px;' />";

echo "<h3 style='margin-top:5px; margin-bottom: 20px;'>Photo Slide Show</h3>";

echo "<table width-='100%' style='margin-left: 25px; margin-bottom: 25px;'>";

$result = mysql_query("SELECT * FROM gallery ORDER BY nm DESC LIMIT 1");
while($row = mysql_fetch_array($result)){$q = substr("$row[1]", 6, 10); $r = ++$q; $galnm = "image $r";}

echo "<tr><td><b>Image Description</b> <br /><input type='text' name='galtxt' value='$row[3]' size='50' style='margin-left: 20px;'></td><td><b>Image</b> <br /><input type='file' name='serv4' id='serv4'><input type='hidden' name='galnm' value='$galnm'></td></tr>";

echo "</table>";

echo "<table width-='100%' style='margin-left: 25px;' cellpadding='5px;' cellspacing='5px'>";

echo "<tr><td valign='top' width='5%' align='center'><font style='color:#f00; font-size:large; font-weight:bold;'>X</font></td>
      <td valign='top' width='50%'><font style='font-size: large; font-weight: bold;'>Photo</font></td>
      <td valign='top' width='45%'><font style='font-size: large; font-weight: bold;'>Photo Information</font></td>
";

$result = mysql_query("SELECT * FROM gallery");
while($row = mysql_fetch_array($result)){$a = substr("$row[3]", 7, 100);
    echo "<tr><td valign='top' width='5%'  align='center'><input type='checkbox' name='checkbox[]' id='checkbox[]' value='$row[0]' style='border: solid 1px #000;'></td>
      <td valign='top' width='50%' align='center' style='background: #C0C0C0;'><img src='http://www.sunwellservice.biz/$row[3]' height='190' width='470' style='border: solid 1px #000;'></td>
      <td valign='top' width='45%'><b>Image Name</b><br />$a<br /><br /><b>Image Description </b><br />$row[4]
";
}

echo "</table>";

echo "</form>";

插入编码:

        $a = $_POST['title'];
        $b = $_POST['welcome'];
        $c = mysql_real_escape_string($_POST['welcome_message']);
        $d = $_POST['services'];
        $e = $_POST['services_list_4'];
        $f = $_POST['services_list_5'];
        $g = $_POST['services_list_6'];
        $h = $_POST['services_list_7'];
        $az = $_POST['services_list_8'];
        $j = $_POST['services_list_9'];
        $k = $_POST['services_list_127'];
        $l = $_POST['services_list_128'];
        $m = $_POST['service'];
        $n = $_POST['serv1'];
        $o = $_POST['serv2'];
        $p = $_POST['serv3'];
        $r = mysql_real_escape_string($_POST['serv1b']);
        $s = mysql_real_escape_string($_POST['serv2b']);
        $t = mysql_real_escape_string($_POST['serv3b']);
        $u = $_POST['news'];
        $v = $_POST['testimonials'];
        $w = $_POST['galtxt'];

        $allowedExts = array("jpg", "jpeg", "gif", "png");

        if($w == TRUE){
            $aa = $_FILES["serv4"]["name"];
            $bb = $_POST['galtxt'];
            $cc = $_POST['galnm'];
            $sql = "INSERT INTO gallery (nm, loc, txt) VALUES ('$cc', 'Home', '$bb')";

            mysql_query($sql);

            $allowedExts = array("jpg", "jpeg", "gif", "png");

            $extension = end(explode(".", $_FILES["serv4"]["name"]));
        if ((($_FILES["serv4"]["type"] == "image/gif")
        || ($_FILES["serv4"]["type"] == "image/jpeg")
        || ($_FILES["serv4"]["type"] == "image/png")
        || ($_FILES["serv4"]["type"] == "image/pjpeg"))
        && ($_FILES["serv4"]["size"] < 2000000)
        && in_array($extension, $allowedExts))
          {
          if ($_FILES["serv4"]["error"] > 0)
            {
            echo "Return Code: " . $_FILES["serv4"]["error"] . "<br>";
            }
          else
            {

            if (file_exists("../front/images/" . $_FILES["serv4"]["name"]))
              {
              echo $_FILES["serv4"]["name"] . " already exists. ";
              }
            else
              {
              move_uploaded_file($_FILES["serv4"]["tmp_name"],
              "../front/images/" . $_FILES["serv4"]["name"]);
            mysql_query("UPDATE gallery SET src='images/$aa' WHERE nm='$cc' AND loc='Home'");
            echo $aa;
              }
            }
          }
        else
          {
          echo "Invalid file";
          }
        }
        else{}


        $checkbox=$_POST['checkbox'];
        for($i=0;$i<count($_POST['checkbox']);$i++){
        $del_id = $checkbox[$i];
        $sql = "DELETE FROM gallery WHERE id='$del_id'";
        $result = mysql_query($sql);}

        if($n == TRUE){
        $extension = end(explode(".", $_FILES["serv1"]["name"]));
        if ((($_FILES["serv1"]["type"] == "image/gif")
        || ($_FILES["serv1"]["type"] == "image/jpeg")
        || ($_FILES["serv1"]["type"] == "image/png")
        || ($_FILES["serv1"]["type"] == "image/pjpeg"))
        && ($_FILES["serv1"]["size"] < 2000000))
          {
          if ($_FILES["serv1"]["error"] > 0)
            {
            echo "Return Code: " . $_FILES["serv1"]["error"] . "<br>";
            }
          else
            {

            if (file_exists("../front/images/" . $_FILES["serv1"]["name"]))
              {
              echo $_FILES["serv1"]["name"] . " already exists. ";
              }
            else
              {
              move_uploaded_file($_FILES["serv1"]["tmp_name"],
              "../front/images/" . $_FILES["serv1"]["name"]);
            mysql_query("UPDATE image_info SET path='images/$n' WHERE nm='serv1' AND loc='Home'");
              }
            }
          }
        else
          {
          echo "Invalid file";
          }
        }
        else{}

        if($o == TRUE){ 
        $extension = end(explode(".", $_FILES["serv2"]["name"]));
        if ((($_FILES["serv2"]["type"] == "image/gif")
        || ($_FILES["serv2"]["type"] == "image/jpeg")
        || ($_FILES["serv2"]["type"] == "image/png")
        || ($_FILES["serv2"]["type"] == "image/pjpeg"))
        && ($_FILES["serv2"]["size"] < 2000000)
        && in_array($extension, $allowedExts))
          {
          if ($_FILES["serv2"]["error"] > 0)
            {
            echo "Return Code: " . $_FILES["serv2"]["error"] . "<br>";
            }
          else
            {

            if (file_exists("../front/images/" . $_FILES["serv2"]["name"]))
              {
              echo $_FILES["serv2"]["name"] . " already exists. ";
              }
            else
              {
              move_uploaded_file($_FILES["serv2"]["tmp_name"],
              "../front/images/" . $_FILES["serv2"]["name"]);
              mysql_query("UPDATE image_info SET path='images/$o' WHERE nm='serv2' AND loc='Home'");
              }
            }
          }
        else
          {
          echo "Invalid file";
          }
          }
        else{}

        if($p == TRUE){
        $extension = end(explode(".", $_FILES["serv3"]["name"]));
        if ((($_FILES["serv3"]["type"] == "image/gif")
        || ($_FILES["serv3"]["type"] == "image/jpeg")
        || ($_FILES["serv3"]["type"] == "image/png")
        || ($_FILES["serv3"]["type"] == "image/pjpeg"))
        && ($_FILES["serv3"]["size"] < 2000000)
        && in_array($extension, $allowedExts))
          {
          if ($_FILES["serv3"]["error"] > 0)
            {
            echo "Return Code: " . $_FILES["serv3"]["error"] . "<br>";
            }
          else
            {

            if (file_exists("../front/images/" . $_FILES["serv3"]["name"]))
              {
              echo $_FILES["serv3"]["name"] . " already exists. ";
              }
            else
              {
              move_uploaded_file($_FILES["serv3"]["tmp_name"],
              "../front/images/" . $_FILES["serv3"]["name"]);
              mysql_query("UPDATE image_info SET path='images/$p' WHERE nm='serv3' AND loc='Home'");
              }
            }
          }
        else
          {
          echo "Invalid file";
          }
        }
        else{}

        mysql_query("UPDATE page_info SET txt='$a' WHERE nm='title' AND loc='Home'");
        mysql_query("UPDATE page_info SET txt='$b' WHERE nm='welcome' AND loc='Home'");
        mysql_query("UPDATE page_info SET txt='$c' WHERE nm='welcome_message' AND loc='Home'");
        mysql_query("UPDATE page_info SET txt='$d' WHERE nm='services' AND loc='Home'");
        mysql_query("UPDATE page_info SET txt='$e' WHERE nm='services_list' AND loc='Home' AND id='4'");
        mysql_query("UPDATE page_info SET txt='$f' WHERE nm='services_list' AND loc='Home' AND id='5'");
        mysql_query("UPDATE page_info SET txt='$g' WHERE nm='services_list' AND loc='Home' AND id='6'");
        mysql_query("UPDATE page_info SET txt='$h' WHERE nm='services_list' AND loc='Home' AND id='7'");
        mysql_query("UPDATE page_info SET txt='$az' WHERE nm='services_list' AND loc='Home' AND id='8'");
        mysql_query("UPDATE page_info SET txt='$j' WHERE nm='services_list' AND loc='Home' AND id='9'");
        mysql_query("UPDATE page_info SET txt='$k' WHERE nm='services_list' AND loc='Home' AND id='127'");
        mysql_query("UPDATE page_info SET txt='$l' WHERE nm='services_list' AND loc='Home' AND id='128'");
        mysql_query("UPDATE page_info SET txt='$m' WHERE nm='service' AND loc='Home'");
        mysql_query("UPDATE page_info SET txt='$r' WHERE nm='serv1b' AND loc='Home'");
        mysql_query("UPDATE page_info SET txt='$s' WHERE nm='serv2b' AND loc='Home'");
        mysql_query("UPDATE page_info SET txt='$t' WHERE nm='serv3b' AND loc='Home'");
        mysql_query("UPDATE page_info SET txt='$u' WHERE nm='news' AND loc='Home'");
        mysql_query("UPDATE page_info SET txt='$v' WHERE nm='testimonials' AND loc='Home'");

        $nm = $_GET['nm'];
        $loc = $_GET['loc'];

        echo"
        <script type='text/javascript'>
            <!--
            window.location = 'site.php?act=edit&nm=".$nm."&loc=".$loc."&nt=upd'
            //-->
        </script>";
4

0 回答 0