spectreinc Posted December 18, 2019 Share Posted December 18, 2019 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> Quote Link to comment https://forums.phpfreaks.com/topic/309704-use-of-undefined-constant-query_string/ Share on other sites More sharing options...
benanamen Posted December 18, 2019 Share Posted December 18, 2019 (edited) As to the specific error, you need to add quotes like so getenv('QUERY_STRING') Additionally, just about everything that could be wrong with this code is wrong. Edited December 18, 2019 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/309704-use-of-undefined-constant-query_string/#findComment-1572603 Share on other sites More sharing options...
cyberRobot Posted December 18, 2019 Share Posted December 18, 2019 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)){ Quote Link to comment https://forums.phpfreaks.com/topic/309704-use-of-undefined-constant-query_string/#findComment-1572654 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.