2012-06-27 2 views
0

나는 php/mysql 프로그래밍에 대한 멍청한 짓을하고 있으며이 양식은 작동하지만 새 컴퓨터를 가지고있을 때는 작동하지 않습니다. HTML은 결과를 PHP 페이지로 보내어 WAMP mysql 데이터베이스로 보낸다. 내가 말했듯이, 나는이 모든 것이 아름답게 작동했다. 나는 WAMP를 다시 설치하고, 데이터베이스와 정보를 복사하여 새로운 기계를 얻었으며, 지금은 나에게주의 사항 만 준다. 그리고 die (mysql_error())를 끝에 추가하면 . $의 SQL은 - ("그것은 예전처럼, 그것은 나에게 연결할 수없는 오류가 있습니다 ..... SELECT색인 및 변수 오류

<?php 
$q=$_GET["q"]; 

$con = mysql_connect("localhost","root","password"); 

if (!$con) 
{ 
    die('Could not connect: ' . mysql_error()); 
} 

mysql_select_db("kalen_qc", $con); 

$sql = ("SELECT `id` FROM `users` WHERE `username` = ' " . $root . " ' and `password` = ' " . $password . " ' limit 1"); 

//Retrieve data from the sql Query String 
$cname = $_GET["cname"]; 
$job = $_GET["job"]; 
$apptype = $_GET["apptype"]; 
$priority = $_GET["priority"]; 
$daterec = $_GET["daterec"]; 
$datereq = $_GET["datereq"]; 
$po = $_GET["po"]; 
$authby = $_GET["authby"]; 
$phone = $_GET["phone"]; 
$fax = $_GET["fax"]; 
$motorplantnumber = $_GET["motorplantnumber"]; 
$quoted = $_GET["quoted"]; 
$incomphoto = $_GET["incomphoto"]; 
$repvalue = $_GET["repvalue"]; 
$eyebolt = $_GET["eyebolt"]; 
$motorassem = $_GET["motorassem"]; 
$conduitbox = $_GET["conduitbox"]; 
$conboxpos = $_GET["conboxpos"]; 
$coupler = $_GET["coupler"]; 
$couplexten = $_GET["couplexten"]; 
$couplrecess = $_GET["couplrecess"]; 
$couplflush = $_GET["couplflush"]; 
$motorweight = $_GET["motorweight"]; 
$motorfreq = $_GET["motorfreq"]; 
$application = $_GET["application"]; 
$appdesc = $_GET["appdesc"]; 
$specinstruc = $_GET["specinstruc"]; 
$reasonserv = $_GET["reasonserv"]; 
$obviousdamage = $_GET["obviousdamage"]; 
$cussupplyprod = $_GET["cussupplyprod"]; 

// Escape User Input to help prevent SQL Injection 
$cname = mysql_real_escape_string($cname); 
$job = mysql_real_escape_string($job); 
$apptype = mysql_real_escape_string($apptype); 
$priority = mysql_real_escape_string($priority); 
$daterec = mysql_real_escape_string($daterec); 
$datereq = mysql_real_escape_string($datereq); 
$po = mysql_real_escape_string($po); 
$authby = mysql_real_escape_string($authby); 
$phone = mysql_real_escape_string($phone); 
$fax = mysql_real_escape_string($fax); 
$motorplantnumber = mysql_real_escape_string($motorplantnumber); 
$incomphoto = mysql_real_escape_string($incomphoto); 
$repvalue = mysql_real_escape_string($repvalue); 
$motorassem = mysql_real_escape_string($motorassem); 
$conduitbox = mysql_real_escape_string($conduitbox); 
$conboxpos = mysql_real_escape_string($conboxpos); 
$coupler = mysql_real_escape_string($coupler); 
$couplexten = mysql_real_escape_string($couplexten); 
$couplrecess = mysql_real_escape_string($couplrecess); 
$couplflush = mysql_real_escape_string($couplflush); 
$motorweight = mysql_real_escape_string($motorweight); 
$motorfreq = mysql_real_escape_string($motorfreq); 
$application = mysql_real_escape_string($application); 
$appdesc = mysql_real_escape_string($appdesc); 
$specinstruc = mysql_real_escape_string($specinstruc); 
$reasonserv = mysql_real_escape_string($reasonserv); 
$obviousdamage = mysql_real_escape_string($obviousdamage); 
$cussupplyprod = mysql_real_escape_string($cussupplyprod); 




$sql="INSERT INTO motor_checkin (cname, job, apptype, priority, daterec, datereq, po, authby, phone, fax, motorplantnumber, quoted, incomphoto, repvalue, eyebolt, motorassem, conduitbox, conboxpos, coupler, couplexten, couplrecess, couplflush, motorweight, motorfreq, application, appdesc, specinstruc, reasonserv, obviousdamage, cussupplyprod) 
VALUES 
('$_GET[cname]','$_GET[job]','$_GET[apptype]','$_GET[priority]','$_GET[daterec]', '$_GET[datereq]','$_GET[po]','$_GET[authby]','$_GET[phone]','$_GET[fax]','$_GET[motorplantnumber]', '$_GET[quoted]','$_GET[incomphoto]','$_GET[repvalue]','$_GET[eyebolt]','$_GET[motorassem]','$_GET[conduitbox]','$_GET[conboxpos]','$_GET[coupler]','$_GET[couplexten]','$_GET[couplrecess]', '$_GET[couplflush]','$_GET[motorweight]','$_GET[motorfreq]','$_GET[application]','$_GET[appdesc]', '$_GET[specinstruc]','$_GET[reasonserv]','$_GET[obviousdamage]','$_GET[cussupplyprod]')"; 



if (!mysql_query($sql,$con)); 
    { 
    die('Error: ' . mysql_error()); 
    } 
header("Location: /"); 

mysql_close($con); 
?> 

HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html> 
<head> 
    <META http-equiv="Content-Typetext/html; charset=iso-8859-1"> 
<title>Kalen Electric Repair Packet</title> 
<link rel="stylesheet" type="text/css" href="qcstyle.css" /> 
<link rel="icon" href="images/favicon.ico" /> 
<!-- This conditional is for IE8 and IE6 and earlier- 8 needs that display:table  --> 
<!--[if !IE 7]> 
<style type="text/css"> 
    #wrap {display:table;height:100%} 
</style> 
<![endif]--> 
<script type="text/javascript"> 
    function showUser(str) 
     { 
      if (str=="") 
       { 
        document.getElementById("txtHint").innerHTML=""; 
        return; 
       } 
      if (window.XMLHttpRequest) 
       {// code for IE7+, Firefox, Chrome, Opera, Safari 
        xmlhttp=new XMLHttpRequest(); 
       } 
      else 
       {// code for IE6, IE5 
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
       } 
        xmlhttp.onreadystatechange=function() 
       { 
      if 
        (xmlhttp.readyState==4 && xmlhttp.status==200) 
       { 
        document.getElementById("txtHint").innerHTML=xmlhttp.responseText; 
       } 
       } 
        xmlhttp.open("GET","insert.php?q="+str,true); 
        xmlhttp.send(); 
       } 
    function loadXMLDoc() 
     { 

     } 
</script> 
</head> 
<body> 
<div id="wrap"> <!-- This wrap div needs to encompass everything except the footer div at bottom --> 

<div id="header"> 
     <div id="logo"> <!-- this extra div is just centering the fixed width area of the header content --> 

      <a href="../index.html"><img src="images/logo.png" alt="Kalen Electric and Machinery Inc Quality Control" class="logo"/></a> 


     </div> 
    </div> 

    <div id="main"> 

    <!-- Inside this main div we are floating the content to the left and the sidebar to the right --> 

     <div id="content"> 

      <h1>Motor Check&#45;In&#58;</h1> 
      <form action="insert.php" method="post" id="horizontalForm"> 
       <div class="box"> 
        <fieldset> 
         <label> 
          <span>Customer&#58;</span> 
         <select class="cname" name="cname"><option value="">Select One</option> <option value="GP Wauna">GP Wauna</option> <option value="GP Toledo">GP Toledo</option> <option value="GP Camas">Gp Camas</option></select> 
         </label> 
         <label> 
         <span>Job Number&#58;</span> 
          <input class="job" type="integer" name="job" onClick="this.value=''"/> 
         </label> 
         <label> 
          <button type="button" onclick="loadXMLDoc()">New Job</button> 
         </label> 
        </fieldset> 
        <fieldset> 
         <label> 
           <span>Apparatus Type&#58 </span> 
          <select class="apptype" name="apptype"> <option value="AC Motor">AC Motor</option> <option value="AC Motor 1ph">AC Motor 1ph</option> <option value="AC Motor/Gearhead">AC Motor/Gearhead</option> 
           <option value="AC Welder">AC Welder</option> <option value="AC Submersible">AC Submersible</option> <option value="Stator Only">Stator Only</option> 
           <option value="Service Call">Service Call</option> <option value="AC Generator">AC Generator</option></select> 
         </label> 
         <label> 
         <span>Priority&#58;</span> 
         <select class="priority" name="priority"> <option value="P1">P1</option> <option value="P2">P2</option> <option value="P3">P3</option></select> 
        </label> 
       </fieldset> 
       <fieldset> 
        <label> 
         <span>Date Received&#58;</span> 
         <input class="daterec" type="date" size="12" maxlength="10" name="daterec" onClick="this.value=''"/> 
        </label> 
        <label> 
         <span>Date Required&#58;</span> 
         <input class="datereq" type="date" size="12" maxlength="10" name="datereq" onClick="this.value=''"/> 
        </label> 
        <label> 
         <span>PO&#35;&#58;</span> 
         <input class="po" type="text" size="12" maxlength="20" name="po" onClick="this.value=''"/> 
        </label> 
        <label> 
         <span>Authorized By&#58;</span> 
         <input class="authby" type="text" size="12" maxlength="30" name="authby" onClick="this.value=''"/> 
        </label> 
       </fieldset> 
       <fieldset> 
        <label> 
         <span>Phone&#35;&#58;</span> 
         <input class="phone" type="text" size="12" maxlength="12" name="phone" onClick="this.value=''"/> 
        </label> 
        <label> 
         <span>Fax&#35;&#58;</span> 
         <input class="fax" type="text" size="12" maxlength="12" name="fax" onClick="this.value=''"/> 
        </label> 
        <label> 
         <span>Motor Plant&#35;&#58;</span> 
         <input class="motorplantnumber" type="text" size="12" maxlength="20" name="motorplantnumber" onClick="this.value=''"/> 
        </label> 
        <label> 
         <span>Quoted&#58;</span> 
         <select class="quoted" name="quoted"> <option value="No">No</option> <option value="Yes">Yes</option></select> 
        </label> 
       </fieldset> 
       <fieldset> 
        <label>     
         <span>Incoming Photo As Received&#58;</span> 
         <select class="incomphoto" name="incomphoto"> <option value="No">No</option> <option value="Yes">Yes</option></select> 
        </label> 
        <label> 
         <span>Replacement Value&#58;</span> 
         <input class="repvalue" type="text" size="12" maxlength="7" name="repvalue" onClick="this.value=''"/> 
        </label> 
        <label> 
         <span>Eye&#45;Bolt&#58</span> 
         <select class="eyebolt" name="eyebolt"> <option value="Good">Good</option> <option value="Bad">Bad</option> <option value="None">None</option></select> 
        </label> 
       </fieldset> 
       <fieldset> 
        <label> 
         <span>Motor Assembly&#58;</span> 
         <select class="motorassem" name="motorassem"> <option value="F1">F1</option> <option value="F2">F2</option> <option value="Vertical">Vertical</option></select> 
        </label> 
        <label> 
         <span>Conduit Box&#58;</span> 
        <select class="conduitbox" name="conduitbox"> <option value="Full">Full</option> <option value="Half">Half</option> <option value="None">None</option></select> 
        </label> 
        <label> 
         <span>Conduit Box Position&#58;</span> 
         <select class="conboxpos" name="conboxpos"> <option value="3:00">3:00</option> <option value="6:00">6:00</option> <option value="9:00">9:00</option> <option value="12:00">12:00</option> </select> 
        </label> 
       </fieldset> 
       <fieldset> 
        <label>  
         <span>Coupler&#47;Pulley&#58;</span> 
         <select class="coupler" name="coupler"> <option value="Coupler">Coupler</option> <option value="Pulley">Pulley</option> <option value="None">None</option> </select> 
        </label> 
        <label> 
         <span>Extended&#58;</span> 
         <input class="couplexten" type="text" size="12" maxlength="10" name="couplexten" onClick="this.value=''"/> 
        </label> 
        <label> 
         <span>Recessed&#58;</span> 
         <input class="couplerecess" type="text" size="12" maxlength="10" name="couplrecess" onClick="this.value=''"/> 
        </label> 
        <label> 
         <span>Flush&#58;</span> 
         <input class="couplflush" type="text" size="12" maxlength="10" name="couplflush" onClick="this.value=''"/> 
        </label> 
       </fieldset> 
       <fieldset> 
        <label> 
         <span>Motor Weight&#58;</span> 
         <input class="motorweight" type="text" size="12" maxlength="10" name="motorweight" onClick="this.value=''"/> 
        </label> 
        <label> 
         <span>Motor On Frequency Drive&#58;</span> 
         <select class="motorfreq" name="motorfreq"> <option value="Yes">Yes</option> <option value="No">No</option> </select> 
        </label> 
       </fieldset> 
       <fieldset> 
        <label> 
         <span>Application&#58;</span> 
         <select class="application" name="application"> <option value="Direct Coupled">Direct Coupled</option> <option value="Belted">Belted</option> </select> 
        </label> 
        <label> 
         <span>Application Description&#58;</span> 
         <input class="appdesc" type="text" size="12" maxlength="100" name="appdesc" onClick="this.value=''"/> 
        </label> 
       </fieldset> 
       <fieldset> 
        <label> 
         <span>Special Instructions&#58;</span> 
         <input class="specinstruc" type="text" size="12" maxlength="255" name="specinstruc" onClick="this.value=''"/> 
        </label> 
       </fieldset> 
       <fieldset> 
        <label> 
         <span>Reason For Service&#58;</span> 
         <input class="reasonserv" type="text" size="12" maxlength="255" name="reasonserv" onClick="this.value=''"/> 
        </label> 
       </fieldset> 
       <fieldset> 
        <label> 
         <span>Obvious Damaged or Missing Parts&#58;</span> 
         <input class="obviousdamage" type="text" size="12" maxlength="255" name="obviousdamage" onClick="this.value=''"/> 
        </label> 
       </fieldset> 
       <fieldset> 
        <label> 
         <span>Customer Supplied Product&#58;</span> 
         <input class="cussupplyprod" type="text" size="12" maxlength="255" name="cussupplyprod" onClick="this.value=''"/> 
        </label> 
       </fieldset> 
      <label> 
      <input type="submit" /><br /> 
      </label> 
      </div> 
     </form> 
    </div> 
</div> 
</div> <!-- close the wrap div here --> 

<div id="footer"> 
    <div id="foot"> <!-- this extra div is just centering the fixed width area of the footer content --> 
     <div id="left"> 
     <p>Kalen Electric and Machinery Inc.</p> 
    </div> 
    <div id="right"> 
     <p>AC Induction - Version 1.0</p> 
    </div> 
</div> 
</div> 

</body> 
</html> 

오류가 반환

(!) Notice: Undefined index: q in C:\wamp\www\insert.php on line 2 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined variable: root in C:\wamp\www\insert.php on line 13 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined variable: sprocket in C:\wamp\www\insert.php on line 13 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: cname in C:\wamp\www\insert.php on line 16 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: job in C:\wamp\www\insert.php on line 17 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: apptype in C:\wamp\www\insert.php on line 18 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: priority in C:\wamp\www\insert.php on line 19 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: daterec in C:\wamp\www\insert.php on line 20 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: datereq in C:\wamp\www\insert.php on line 21 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: po in C:\wamp\www\insert.php on line 22 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: authby in C:\wamp\www\insert.php on line 23 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: phone in C:\wamp\www\insert.php on line 24 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: fax in C:\wamp\www\insert.php on line 25 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: motorplantnumber in C:\wamp\www\insert.php on line 26 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: quoted in C:\wamp\www\insert.php on line 27 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: incomphoto in C:\wamp\www\insert.php on line 28 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: repvalue in C:\wamp\www\insert.php on line 29 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: eyebolt in C:\wamp\www\insert.php on line 30 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: motorassem in C:\wamp\www\insert.php on line 31 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: conduitbox in C:\wamp\www\insert.php on line 32 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: conboxpos in C:\wamp\www\insert.php on line 33 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: coupler in C:\wamp\www\insert.php on line 34 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: couplexten in C:\wamp\www\insert.php on line 35 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: couplrecess in C:\wamp\www\insert.php on line 36 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: couplflush in C:\wamp\www\insert.php on line 37 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: motorweight in C:\wamp\www\insert.php on line 38 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: motorfreq in C:\wamp\www\insert.php on line 39 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: application in C:\wamp\www\insert.php on line 40 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: appdesc in C:\wamp\www\insert.php on line 41 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: specinstruc in C:\wamp\www\insert.php on line 42 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: reasonserv in C:\wamp\www\insert.php on line 43 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: obviousdamage in C:\wamp\www\insert.php on line 44 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: cussupplyprod in C:\wamp\www\insert.php on line 45 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: cname in C:\wamp\www\insert.php on line 85 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: job in C:\wamp\www\insert.php on line 85 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: apptype in C:\wamp\www\insert.php on line 85 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: priority in C:\wamp\www\insert.php on line 85 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: daterec in C:\wamp\www\insert.php on line 85 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: datereq in C:\wamp\www\insert.php on line 86 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: po in C:\wamp\www\insert.php on line 86 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: authby in C:\wamp\www\insert.php on line 86 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: phone in C:\wamp\www\insert.php on line 86 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: fax in C:\wamp\www\insert.php on line 86 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: motorplantnumber in C:\wamp\www\insert.php on line 86 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: quoted in C:\wamp\www\insert.php on line 87 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: incomphoto in C:\wamp\www\insert.php on line 87 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: repvalue in C:\wamp\www\insert.php on line 87 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: eyebolt in C:\wamp\www\insert.php on line 87 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: motorassem in C:\wamp\www\insert.php on line 87 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: conduitbox in C:\wamp\www\insert.php on line 88 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: conboxpos in C:\wamp\www\insert.php on line 88 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: coupler in C:\wamp\www\insert.php on line 88 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: couplexten in C:\wamp\www\insert.php on line 88 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: couplrecess in C:\wamp\www\insert.php on line 88 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: couplflush in C:\wamp\www\insert.php on line 89 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: motorweight in C:\wamp\www\insert.php on line 89 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: motorfreq in C:\wamp\www\insert.php on line 89 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: application in C:\wamp\www\insert.php on line 89 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: appdesc in C:\wamp\www\insert.php on line 89 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: specinstruc in C:\wamp\www\insert.php on line 90 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: reasonserv in C:\wamp\www\insert.php on line 90 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: obviousdamage in C:\wamp\www\insert.php on line 90 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 

(!) Notice: Undefined index: cussupplyprod in C:\wamp\www\insert.php on line 90 
Call Stack 
# Time Memory Function Location 
1 0.0006 744072 {main}() ..\insert.php:0 
+0

Wamp를 사용하고 계십니까? 새 컴퓨터에 Wamp를 재설치하고 올바르게 설정 했습니까? – javajavajava

+0

모든 오류가 이미 나열되고 있습니다. 하나씩 삭제 해보십시오. – hjpotter92

+0

[PHP : "Notice : Undefined variable"및 "Notice : Undefined index"] 복제본 (http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and- notice-undefined-index) – mario

답변

1

그것들은 오류가 아니라 모든 고지입니다. ost 새로운 PHP 설치는보다 엄격한 오류보고 수준을 가지며 이전 컴퓨터는 동일한주의 사항을 차단했을 가능성이 큽니다.

통지 자체는 아직 양식이 제출되지 않았거나 양식 데이터가 전송되지 않은 다른 관련 문제가 있음을 의미합니다.

0

변수 ("q", "root", "sprocket"등)는 다른 페이지에서 가져와야하므로 $ _GET 호출이되어야합니다. 먼저 양식을 실행 해 보셨습니까? 이 페이지를 단순히로드하는 중이면 변수가 채워지지 않습니다.

4

답변은 통지 자체에 있습니다. q에 대한 항목이 쿼리 문자열에 없습니다.

오류 처리 및 입력 유효성 검사를 작성하여 해당 변수가 존재하는지 확인하는 것이 가장 좋습니다.

$q = (isset($_GET['q']) ? $_GET['q'] : null); 

여러 변수를 설정하고 참조하기 때문에 해당 변수를 전달할 수있는 함수를 만드는 것이 좋습니다. 이는 해당 변수의 존재 여부를 검사 할뿐만 아니라 쿼리에서 사용할 변수를 이스케이프합니다.

<?php 
function varExist($var){  
    return (isset($_GET[$var]) ? mysql_real_escape_string($_GET[$var]) : null);  
} 
$q = varExist('q'); 
...  
?> 

documentation 당 있다는 점 유의 하시길 바랍니다 :이 확장의

사용은 권장되지 않습니다. 대신 MySQLi 또는 PDO_MySQL 확장자를 사용해야합니다. 자세한 내용은 MySQL : API 가이드 선택 및 관련 FAQ를 참조하십시오. 이 기능 대안은 다음과 같습니다

■ mysqli_real_escape_string을() ■ PDO :: 따옴표()

검토 할 수 있다는 제안 된 대안 mysqli_real_escape_string()에 관한 추가 문서가있다

.

2

기본적으로 모든 변수는 비어 있습니다. 코드 시작 부분에 초기화해야합니다. 이렇게하면 정의되지 않은 색인 경고가 발생하지 않습니다.

$q = ''; 
$cname = ''; 
...etc 

사이드 참고

이 정말 정말 위험합니다. SQL을 실행할 때 $ _Get을 절대로 사용하지 마십시오.사용자는 그런 식으로 SQL 주입 공격을 수행 할 수 있습니다.

INSERT ... Values ('$_GET[cname]','$_GET[job]' 

귀하의 경우에는

$cname = mysql_real_escape_string($cname); 
$job = mysql_real_escape_string($job); 
Insert ... Values (' . $cname . ', ' . $job . ' 
+0

죄송합니다. HTML 페이지를 게시하지 않았습니다. –

+0

빈 값이나 null 값을 피하기 위해 변수를 초기화하기 전에 변수를 초기화 할 수는 있지만 솔루션에 게시 된 경로를 제안합니다. 이는 DRY를 연습 할뿐만 아니라 코드를 훨씬 읽기 쉽고 유지 보수하기 쉽게 만듭니다. – RobB

+0

나는 @RobB에 동의해야 할 것입니다. 당신의 솔루션은 훨씬 더 간결했으며 앞으로 사용하게 될 것입니다. –

0

훨씬 더 나은이 갈 방법이 될 수 있습니다 : 스크립트의 첫 번째 라인이 설정 :

// Report all errors except E_NOTICE 
error_reporting(E_ALL^E_NOTICE); 

이것은 단순히 것 "오류"메시지가 나타납니다. 이것은 코드 작성에 좋은 방법은 아니지만,이 경우에는 가장 빠른 빠른 & 해결책입니다.

+3

나는 이것이 메시지를 빨리 제거한다는 것에 동의하지만, 오류보고를 계속하면 코드 논리에서 간단한 실수를하지 않게됩니다. –

+0

@JoshFrankel 전적으로 당신에게 동의합니다,하지만 그는 코더가 아니라고 말하고 단지이 일을 실행하기를 원합니다. 그래, 괜찮아. – Sliq