2016-04-10 24 views
-1
Ben php kullanarak mySQL veritabanını güncellemeye çalışıyorum

kullanarak ancak im bazı hata sahip: Aşağıdakihata güncelleme MySQL veritabanı php

Parse error: syntax error, unexpected '}', expecting end of file in C:\xampp\htdocs\SLR\Update S110 PC01.php on line 29

Kodu:

<?php 
$servername = "localhost"; 
$username = "root"; 
$password = ""; 
$dbname = "slr"; 

// Create connection 
$conn = new mysqli($servername, $username, $password, $dbname); 
// Check connection 
if ($conn->connect_error) { 
    die("Connection failed: " . $conn->connect_error); 
} 

$soft_id = $_POST['soft_id']; 
$soft_name = $_POST['soft_name']; 
$installed_date = $_POST['installed_date']; 
$expiry_date = $_POST['expiry_date']; 
$product_key = $_POST['product_key']; 

$sql = "UPDATE s110_pc01 ". "SET soft_name = $soft_name ". 
       "WHERE soft_id = $soft_id" ; 
$retval = mysql_query($sql, $link); 

if(! $retval) { 
       die('Could not update data: ' . mysql_error()); 
      } 
      echo "Updated data successfully\n"; 
mysql_close($link); 
}else { 
      ?> 
<form method = "post" action = "<?php $_PHP_SELF ?>"> 
        <table width = "400" border =" 0" cellspacing = "1" 
        cellpadding = "2"> 

        <tr> 
         <td width = "100">Software ID</td> 
         <td><input name = "soft_id" type = "text" 
          id = "soft_id"></td> 
        </tr> 

     <tr> 
         <td width = "100">Software Name</td> 
         <td><input name = "soft_name" type = "text" 
          id = "soft_name"></td> 
        </tr> 
+0

Hatanızın bahsettiği satır 29'a bakın. Kodunuzu girerseniz, hiçbir şey ifade etmediğini görürsünüz ('if (! $ Retval) {' siz öldükten sonra sona erer). Bu 'else' etiket referansı nedir? – h2ooooooo

+0

'mysql_error' ve' mysql_close' mysql ** i ** bağlantısında mı? – Xorifelse

+0

bilmiyorum, ben juz bu kodu internetten aldı ve değiştirdi ... lütfen çözmeme yardım edin ... –

cevap

0

sonra aşağıyı deneyin
<?php 
$servername = "localhost"; 
$username = "root"; 
$password = ""; 
$dbname = "slr"; 

// Create connection 
$conn = new mysqli($servername, $username, $password, $dbname); 
// Check connection 
if ($conn->connect_error) { 
    die("Connection failed: " . $conn->connect_error); 
} 

$soft_id = $_POST['soft_id']; 
$soft_name = $_POST['soft_name']; 
$installed_date = $_POST['installed_date']; 
$expiry_date = $_POST['expiry_date']; 
$product_key = $_POST['product_key']; 

$sql = "UPDATE s110_pc01 ". "SET soft_name = $soft_name ". 
       "WHERE soft_id = $soft_id" ; 
$retval = mysql_query($sql, $link); 


if($retval) { 
    echo "Updated data successfully\n";  
} else { 
die('Could not update data: ' . mysql_error());   
mysql_close($link); 
} 
?> 
<form method = "post" action = "<?php $_PHP_SELF ?>"> 
        <table width = "400" border =" 0" cellspacing = "1" 
        cellpadding = "2"> 

        <tr> 
         <td width = "100">Software ID</td> 
         <td><input name = "soft_id" type = "text" 
          id = "soft_id"></td> 
        </tr> 

     <tr> 
         <td width = "100">Software Name</td> 
         <td><input name = "soft_name" type = "text" 
          id = "soft_name"></td> 
        </tr>