Jump to content

Recommended Posts

im getting these errors Notice: Use of undefined constant QUERY_STRING - assumed 'QUERY_STRING' in C:\xampps\htdocs\skyline\admin\other.php on line 36  and  
Notice: Undefined variable: update in C:\xampps\htdocs\skyline\admin\other.php on line 67

 

<?php
    $hostname = "localhost";
    $dbname = "pricelist";
    $username = "root";
        $password = "";
    
        $conn = new MySQLi($hostname, $username, $password, $dbname) or die('Can not connect to database')        
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<otype></otype>
</head>
<body>
<?php
    if(isset($_POST['Submit'])){
    
    
    $oname = $_POST['updateoname'];
    
    $otype = $_POST['updateotype'];
    
    $ocost = $_POST['updateocost'];
    
    $onotes = $_POST['updateonotes'];
        
    $update = "UPDATE other SET oname='$oname', otype='$otype', ocost='$ocost', onotes='$onotes' WHERE id = ".$id;
    $conn->query($update) or die("Cannot update");
    }
?>
<?php

$sql = "SELECT * FROM other ";
$result = $conn->query($sql) or die(mysql_error());
$query=getenv(QUERY_STRING);
parse_str($query);
?>
<h2>Update Record </h2>
<form action="" method="post">
<?php
    
    
    while ($row = $result->fetch_assoc()) {?>
    
<table border="0" cellspacing="10">
<tr>
<td>otype:</td> <td><input type="text" name="updateotype" value="<?php echo $row['otype']; ?>"></td>
</tr>
<tr>
<td>ocost:</td> <td><input type="text" name="updateocost" value="<?php echo $row['ocost']; ?>"></td>
</tr>
<tr>
<td>name:</td> <td><input type="text" name="updateoname" value="<?php echo $row['oname']; ?>"></td>
</tr>
<tr>
<td>onotes URL:</td> <td><input type="text" name="updateonotes" size="100" value="<?php echo $row['onotes']; ?>"></td>
</tr>
<tr>
<td><INPUT TYPE="Submit" VALUE="Update the Record" NAME="Submit"></td>
</tr>
</table>
<?php    }
    ?>
</form>
<?php
    if($update){
    
    echo "<b>Update successful!</b>";
    
    
        
}  
?>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/309704-use-of-undefined-constant-query_string/
Share on other sites

17 hours ago, spectreinc said:

Notice: Undefined variable: update in C:\xampps\htdocs\skyline\admin\other.php on line 67

As for the other error, $update isn't defined unless the form is submitted. You could add isset() to the following line:

if(isset($update)){

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.