PHP - I Am Getting Undefined Index Error When I Am Trying To Echo Out The Function.help Me. I Am A Php Newbie.
<?php
Similar TutorialsIts my first attempt at php so please assume you are talking to a 3year old please. i keep getting an Undefined index for addartist but i have no idea whats wrong. </head> <body> <?php // Αν ο χρήστης θελήσει να προσθέσει ένα φίλο // Σύνδεση με τον database server $dbcnx = @mysql_connect("localhost", "root", ""); if (!$dbcnx) die('Could not connect: ' . mysql_error()); // Επιλογή της βάσης δεδομένων ergasia if (! @mysql_select_db("ergasia") ) die('Αδύνατος ο εντοπισμός της βάσης δεδομένων ergasia: ' . mysql_error()); //mysql_query("SET CHARACTER SET 'utf8'"); mysql_query("SET NAMES 'utf8'", $dbcnx); if ($_REQUEST['addartist']==1): ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get" onsubmit="return checkForm()"> <P> Δώστε παρακάτω τα στοιχεία του καλιτεχνη σας : <br /> Όνομα: <input type="text" name="FirstName" id="FirstName" /><br /> Επώνυμο: <input type="text" name="LastName" id="LastName" /><br /> Ετος Γέννησης: <input type="text" name="BirthDate" id="BirthDate" /> <br /> Ετος Θανατου: <input type="text" name="DeathDate" id="DeathDate" /> <br /> </select> <input type="submit" name="SubmitArtist" value="Αποθήκευση" /> <br /> </form> <?php else: // Αν έχει υποβληθεί ένας καλιτεχνης, το προσθέτουμε στη βάση δεδομένων, αφού ελέγξουμε το BirthDate και το DeathDate if (isset($_REQUEST["SubmitArtist"])) { $BirthDate=trim($_REQUEST["BirthDate"]); $DeathDate=trim($_REQUEST["DeathDate"]); // ΕΛΕΓΧΟΣ ΗΜΕΡΟΜΗΝΙΑΣ if (!preg_match("[0-9]{4}",$_REQUEST["BirthDate"])) { echo "Wrong Birth Year Format!! Please press back and change date."; exit(); } if (!preg_match("[0-9]{4}",$_REQUEST["DeathDate"])) { echo "Wrong Death Year Format!! Please press back and change date."; exit(); } $sql="INSERT INTO artists (LastName, FirstName, BirthDate, DeathDate)" . "VALUES ('$_REQUEST[LastName]','$_REQUEST[FirstName]', '$_REQUEST[BirthDate]', '$_REQUEST[DeathDate]')"; if (mysql_query($sql)) echo("<P> Ο Καλιτεχνης έχει προστεθεί. </P>"); else echo("<P> Λάθος στην προσθήκη του καλιτεχνη : " . mysql_error() . "</P>"); } // Αν επιλέχθηκε να διαγραφεί ένας καλιτεχνης, το αφαιρούμε από τη βάση δεδομένων if (isset($_REQUEST['deleteartist'])) { $sql = "DELETE FROM artists " . "WHERE ID=" . $_REQUEST[deleteartist]; if (mysql_query($sql)) { echo("<P> Ο καλιτεχνης έχει διαγραφεί. </P>"); } else { echo("<P> Λάθος στη διαγραφή του καλιτεχνη : " . mysql_error() . "</P>"); } } echo("<P> Λιστα Καλιτεχνων : </P>"); // Αναζήτηση (request) των εγγραφών όλων των φίλων σας $sql = "SELECT ID, LastName, FirstName, BirthDate, DeathDate"; if (isset($_REQUEST["orderby"])) $sql = $sql . " ORDER BY " . $_REQUEST[orderby]; $result = mysql_query($sql); if (!$result) { echo("<P> Λάθος στην εκτέλεση του query : " . mysql_error() . "</P>"); exit(); } ?> <table border="1"> <tr> <td><a href="<?php echo $_SERVER['PHP_SELF']; ?>?orderby=LastName">Επώνυμο</a></td> <td><a href="<?php echo $_SERVER['PHP_SELF']; ?>?orderby=FirstName">Όνομα</a></td> <td><a href="<?php echo $_SERVER['PHP_SELF']; ?>?orderby=BirthDate">Ετος Γενησης</a></td> <td><a href="<?php echo $_SERVER['PHP_SELF']; ?>?orderby=DeathDate">Ετος Θανατου</a></td> <td><br /></td> </tr> <?php // Εμφάνιση των στοιχείων των κααλιτεχνων σε ένα πίνακα // με ένα link "Αφαίρεση Καλιτεχνγ" δίπλα στον καθένα while ( $row = mysql_fetch_array($result) ) { $artistid = $row["ID"]; echo "<tr><td>" . $row["LastName"] . "</td><td>" . $row["FirstName"] . "</td>"; echo "<td>" . $row["BirthDate"] . "</td><td>" . $row["DeathDate"] . "</td>"; echo "<td><a href='" . $_SERVER['PHP_SELF'] . "?deleteartist=$artistid'>Αφαίρεση κκαλιτεχνη</a></td></tr>"; } echo "</table>"; // Όταν γίνει κλικ, αυτό το link θα φορτώσει αυτή τη σελίδα // με εμφανισμένη τη φόρμα υποβολής καλιτεχνη echo "<p><a href='" . $_SERVER['PHP_SELF'] . "?addartist=1'>Πρόσθεσε ένα Καλιτεχνη</a></p>"; endif; ?> </body> </html> I am trying to delete some videos. The videos are echo'd out individually with their own 'delete' input. The input value takes the id of the video, I didn't know of any other work around for that. I'd like to delete the video that corresponds with the button pressed, if that makes sense. Anyways, I would like to delete the video where the video id is equal to the video id of the input or the value of the input pressed. I am positive the way I am carrying this out is not correct, as I am thrown an 'index undefined error'. Here is the disgusting code at hand. Recommendations are appreciated, but please try and keep answers in line with the relevant information given. Thank You.
<?php error_reporting(-1); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); require('dbcon/dbcon.php'); include('header.php'); include('user.php'); $channel_id = $_SESSION['channel_id']; $query = $pdo->prepare("SELECT * FROM videos001 WHERE uploader = :channel_id"); $query->bindValue('channel_id', $_SESSION['channel_id']); $query->execute(); while ($row = $query->fetch(PDO::FETCH_ASSOC)) { $title = $row['video_title']; $video_path = $row['video_path']; $video_id = $row['video_id']; /* - get videos of user - display videos out onto page */ ?> <html> <body> <div class="content"> <form method="post"> <h3><?php echo $title; ?></h3> <input type="button" name="delete" id="delete" value="<?php echo $video_id;?>" onclick="deleteVideo()"> </form> </div> </body> </html> <?php } function removeVideoFromFilesystem(PDO $pdo, $video_path, $video_id) { //chdir($video_path); //unlink($video_id . ".mp3"); $query = $pdo->prepare("DELETE from videos001 where video_id = :video_id"); $query->bindValue(':video_id', $_POST['delete']); $query->execute(); } if (isset($_POST['call_func'])) { removeVideoFromFileSystem($pdo, $video_path, $_POST['delete']); } ?> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> function deleteVideo() { $.ajax({ url: 'dashboard.php', type: 'post', data: {"call_func":"1"}, success: function(response) { console.log(response); } }); } </script> </head> <body><?php print_r($_POST['delete']); ?></body> </html>
How do I get my session to be unset? My form looks like this: foreach ($joined as $i => $qty){ echo "<form action='' method='get' name='yourForm'>"; echo "<button type='submit' name='remove_" . $i . "' value='remove_" . $i . "' class='deletebtn' >X</button>"; echo "</form>"; } My SESSION is defined like this: for($i=0; $i<=5; $i++){ if (isset($_REQUEST["element_id_$i"]) ) { $_SESSION["element_id_$i"] = $_REQUEST["element_id_$i"]; $id = $_SESSION["element_id_$i"]; array_push($_SESSION["element_id"],$id); } $id = $_SESSION["element_id"]; } and the form submits to: if (isset($_REQUEST["remove_$i"]) ){ unset($_SESSION["quantity[$i]"]); unset($_SESSION["element_id[$i]"]); var_dump($_SESSION["element_id"]); var_dump($_SESSION["quantity"]); echo "Received variable " . $_REQUEST["remove_$i"]; echo 'TARGET INDEX TO BE REMOVED: ' . $_SESSION["element_id[$i]"] . '<br><br>'; } The output is:
array(1) { [0]=> string(1) "1" } array(1) { [0]=> string(1) "1" } Received variable remove_1 Hi I am working on a php module and I am getting this "Notice: Undefined index:" Error. Now I know that I can change my php settings to not show the error but I would like to fix it properly. What am I doing wrong? <?php function _com_slider_image_styles() { $styles = &drupal_static(__FUNCTION__); // Grab from cache or build the array. if (!isset($styles)) { if ($cache = cache_get('image_styles', 'cache')) { $styles = $cache->data; } else { // Select all the user-defined styles. $user_styles = db_select('image_styles', NULL, array('fetch' => PDO::FETCH_ASSOC)) ->fields('image_styles') ->orderBy('name') ->execute() ->fetchAllAssoc('name', PDO::FETCH_ASSOC); } } $com_styles = null; foreach($styles as $key => $value){ $com_styles[$key] .= $key; // PROBLEM HERE! } return $com_styles; } ?> Hi, I'm trying to create a cms and keep getting an undefined index:action error message. I tried to use isset but then it just threw out a different error. The section of code that is causing the errors is: if ( $_GET['action'] != "login" && $_GET['action'] != "logout" && !$_SESSION['username'] ){ //ITS SHOWING 2 ERRORS WITH ACTION ON THIS LINE login(); exit; } switch ( $_GET['action'] ) { //IT ALSO HAS AN ERROR FOR ACTION ON THIS LINE case 'login': login(); break; case 'logout': logout(); break; I would really appreciate the help as it's been annoying me and i'm having a mental blog. Thanks in advance. I get this error
Notice: Undefined index: loggedIn in C:\xampp\htdocs\Login\web_dir\index.php on line 6The code for line 6 is if($_SESSION['loggedIn'] !== 1) { I have a really simple e-mail form that I made a while ago. I'm trying to make a simple modification, but I'm getting a a logical error somewhere. The problem is with the one optional variable ($wholesale) that gets sent to the PHP script. If the user has clicked the box on the form and the $wholesale variable has something in it, the message gets sent without an error. But if the user leaves the box blank, nothing is in the variable and PHP has a problem with that. It'll still send the e-mail, but I get a Notice: Undefined index: wholesale in /file/path/on our/sever.com/send_form_email.php on line 35 error. Here's a part of the code: // validation expected data exists if(!isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['street_address']) || !isset($_POST['city']) || !isset($_POST['state']) || !isset($_POST['zip']) || !isset($_POST['phone'])) { died('We are sorry, but there appears to be a problem with the form your submitted.'); } $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $street_address = $_POST['street_address']; // required $city = $_POST['city']; // required $state = $_POST['state']; // required $zip = $_POST['zip']; // required $phone = $_POST['phone']; // required $wholesale = $_POST['wholesale']; // not required // I don't see why this isn't solving the problem if ( $_POST['wholesale'] == null ) { $wholesale = "."; } ... then the code formats and sends the e-mail out. Any help would be awesome... this is such a simple thing that I honestly can't think of what else to try... I am working on building a newsletter with PHP. I have gotten everything to work but the pulling of the email address.
First is the sendnl.php file
<?php require("../PHPMailer/class.phpmailer.php"); include 'includes.php'; $mail = new PHPMailer; $subject = $_POST['subject']; $text = $_POST['newsletterBody']; $mail->IsSMTP(); $mail->Host = 'localhost'; $mail->Port = '465'; $mail->SMTPAuth = true; $mail->Username = '******USERNAME'; $mail->Password = '*****PASSWORD'; $mail->SMTPAuth = true; $mail->SMTPSecure = 'ssl'; $mail->From = '***EMAIL'; $mail->FromName = '****FROMNAME'; $email = getEmail("73", $DBH); foreach ($email as $nlEmail) { $addEmail = $nlEmail->email; $mail->AddAddress($addEmail); $DBH = null; $addEmail = ""; } $mail->AddReplyTo('******EMAIL', '*****EMAILNAME'); $mail->WordWrap = 50; $mail->IsHTML(true); $mail->Subject = $subject; $mail->Body = $text; $mail->AltBody = $text; if(!$mail->Send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; exit; } echo 'Message has been sent'; ?>Next is part of the includes file going over the function and class function getEmail($inId, $DBH) { if (!empty($inId)) { $blogstmt = $DBH->prepare("SELECT email_addr FROM newsletter_emails WHERE id = :userId"); $blogstmt->bindParam(":userId", $inId, PDO::PARAM_STR, 6); $blogstmt->execute(); } else { $blogstmt = $DBH->prepare("SELECT * FROM newsletter_emails"); $blogstmt->execute(); } $postArray = array(); $results = $blogstmt->fetchAll(PDO::FETCH_ASSOC); foreach($results as $row){ $myPost = new nlEmails($row["id"], $row['email'], $DBH); array_push($postArray, $myPost); } return $postArray; $DBH = null; } class nlEmails { public $id; public $email; function __construct($inId=null, $inEmail=null, $DBH) { if(!empty($inId)) { $this->id = $inId; } if(!empty($inEmail)) { $this->email = $inEmail; } } }It gives me an Unidentified index error message for the "id" and "email" used in the getEmail function. Thanks for any help or pointers. Edited by travisco87, 08 October 2014 - 03:33 PM. Hi all.Here is a part of my scripts . When I run it with my hosting server it works very well , but when I run it in ubuntu lampp , it keeps giving me these errors: Notice: Undefined index: txtFirstName in /opt/lampp/htdocs/EMC/customer-search.php on line 123 Notice: Undefined index: txtLastName in /opt/lampp/htdocs/EMC/customer-search.php on line 123 Notice: Undefined index: txtCell in /opt/lampp/htdocs/EMC/customer-search.php on line 123 Notice: Undefined index: txtGroup in /opt/lampp/htdocs/EMC/customer-search.php on line 123 Notice: Undefined variable: id in /opt/lampp/htdocs/EMC/customer-search.php on line 247 Notice: Undefined index: Page in /opt/lampp/htdocs/EMC/customer-search.php on line 253 Notice: Undefined index: Page in /opt/lampp/htdocs/EMC/customer-search.php on line 254 Here is the code: Code: [Select] <html> <body> <form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>"> <table width="599" border="1"> <tr> <th>Keyword <input name="txtFirstName" type="text" id="txtFirstName" value="<?=$_GET["txtFirstName"];?>"> <input name="txtLastName" type="text" id="txtLastName" value="<?=$_GET["txtLastName"];?>"> <input name="txtCell" type="text" id="txtCell" value="<?=$_GET["txtCell"];?>"> <? $opselect="SELECT DISTINCT Custgroup FROM UserAddedRecord"; $result = mysql_query ($opselect); while($nt=mysql_fetch_array($result)) { ?> <option><?= $nt[Custgroup]?></option>"; <? } ?> </select> <input type="submit" value="Search"> </tr> </table> </form> <? if($_GET["txtFirstName"] != "" || $_GET["txtLastName"] != "" || $_GET["txtCell"] != "" || $_GET["txtGroup"] != "") { $objConnect = mysql_connect("localhost","root","") or die(mysql_error()); $objDB = mysql_select_db("EMC"); // Search By Name or Email $strSQL = "SELECT * FROM UserAddedRecord WHERE (FirstName LIKE '%".$_GET["txtFirstName"]."%' and LastName LIKE '%".$_GET["txtLastName"]."%' and Cell LIKE '%".$_GET["txtCell"]."%' and Custgroup LIKE '%".$_GET["txtGroup"]."%')"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $Num_Rows = mysql_num_rows($objQuery); $Per_Page = 2; // Per Page $Page = $_GET["Page"]; if(!$_GET["Page"]) { $Page=1; } $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) { $Num_Pages =1; } else if(($Num_Rows % $Per_Page)==0) { $Num_Pages =($Num_Rows/$Per_Page) ; } else { $Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages; } $strSQL .=" order by id DESC LIMIT $Page_Start , $Per_Page"; $objQuery = mysql_query($strSQL); ?> <table width="600" border="1"> <tr> <th width="50"> <div align="center">#</div></th> <th width="91"> <div align="center">CustomerID </div></th> <th width="98"> <div align="center">Name </div></th> <th width="198"> <div align="center">Email </div></th> <th width="97"> <div align="center">CountryCode </div></th> <th width="59"> <div align="center">Budget </div></th> <th width="71"> <div align="center">Used </div></th> </tr> <? while($objResult = mysql_fetch_array($objQuery)) { ?> <tr> <td><div align="center"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?=$objResult["id"];?>"></div></td> <td><div align="center"><?=$objResult["id"];?></div></td> <td><?=$objResult["FirstName"];?></td> <td><?=$objResult["LastName"];?></td> <td><div align="center"><?=$objResult["MobileCompany"];?></div></td> <td align="right"><?=$objResult["Cell"];?></td> <td align="right"><?=$objResult["Workphone"];?></td> </tr> <? } ?> </table> <br> Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page : <? if($Prev_Page) { if($_GET["txtFirstName"] == "") { echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtLastName=$_GET[txtLastName]'><< Back</a> "; } else { echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtFirstName=$_GET[txtFirstName]'><< Back</a> "; } } for($i=1; $i<=$Num_Pages; $i++){ if($i != $Page) { echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtFirstName=$_GET[txtFirstName]'>$i</a> ]"; } else { echo "<b> $i </b>"; } } if($Page!=$Num_Pages) { if($_GET["txtFirstName"] == "" && $_GET["txtLastName"] == "" && $_GET["txtCell"] == "") { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtGroup=$_GET[txtGroup]'>Next>></a> "; } else if($_GET["txtFirstName"] == "" && $_GET["txtLastName"] == "") { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtCell=$_GET[txtCell]'>Next>></a> "; } else if($_GET["txtFirstName"] == "" ) { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtLastName=$_GET[txtLastName]'>Next>></a> "; } else { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtFirstName=$_GET[txtFirstName]'>Next>></a> "; } } mysql_close($objConnect); } else { $strSQL = "SELECT * FROM UserAddedRecord WHERE user_id='$id'"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $Num_Rows = mysql_num_rows($objQuery); $Per_Page = 2; // Per Page $Page = $_GET["Page"]; if(!$_GET["Page"]) { $Page=1; } $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) { $Num_Pages =1; } else if(($Num_Rows % $Per_Page)==0) { $Num_Pages =($Num_Rows/$Per_Page) ; } else { $Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages; } $strSQL .=" order by id DESC LIMIT $Page_Start , $Per_Page"; $objQuery = mysql_query($strSQL); ?> <table width="600" border="1"> <tr> <th width="50"> <div align="center">#</div></th> <th width="91"> <div align="center">ID </div></th> <th width="198"> <div align="center">First Name </div></th> <th width="198"> <div align="center">Last Name </div></th> <th width="250"> <div align="center">Mobile Company </div></th> <th width="100"> <div align="center">Cell </div></th> <th width="100"> <div align="center">Workphone </div></th> <th width="100"> <div align="center">Group </div></th> </tr> <? echo "<form name='form1' method='post' action=''>"; while($objResult = mysql_fetch_array($objQuery)) { echo "<tr>"; echo "<td align='center'><input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"$objResult[addedrec_ID]\"></td>"; echo "<td>$objResult[addedrec_ID] </td>"; echo "<td>$objResult[FirstName]</td>"; echo "<td>$objResult[LastName] </td>"; echo "<td>$objResult[MobileCompany] </td>"; echo "<td>$objResult[Cell] </td>"; echo "<td>$objResult[WorkPhone] </td>"; echo "<td>$objResult[Custgroup] </td>"; echo "</tr>"; } echo "<td colspan='7' align='center'><input name=\"delete\" type=\"submit\" id=\"delete\" value=\"Delete\">"; if($_POST['delete']) // from button name="delete" { $checkbox = $_POST['checkbox']; //from name="checkbox[]" $countCheck = count($_POST['checkbox']); for($d=0;$d<$countCheck;$d++) { $del_id = $checkbox[$d]; $sql = "DELETE from UserAddedRecord where addedrec_ID = $del_id"; $result2=mysql_query($sql); } if($result2) { header('Location: customer-adddata.php'); } else { echo "Error: ".mysql_error(); } } echo "</form>"; ?> </table> <br> Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page : <? if($Prev_Page) { if($_GET["txtFirstName"] == "") { echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtLastName=$_GET[txtLastName]'><< Back</a> "; } else { echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtFirstName=$_GET[txtFirstName]'><< Back</a> "; } } for($i=1; $i<=$Num_Pages; $i++){ if($i != $Page) { echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtFirstName=$_GET[txtFirstName]'>$i</a> ]"; } else { echo "<b> $i </b>"; } } if($Page!=$Num_Pages) { if($_GET["txtFirstName"] == "" && $_GET["txtLastName"] == "") { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtCell=$_GET[txtCell]'>Next>></a> "; } else if($_GET["txtFirstName"] == "" ) { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtLastName=$_GET[txtLastName]'>Next>></a> "; } else { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtFirstName=$_GET[txtFirstName]'>Next>></a> "; } } mysql_close($objConnect); } ?> </body> </html> Can I know how to solve this problem? Thanks in advanced. I have a simple problem but seem to be hitting a roadblock with fixing it. I am in the process of upgrading a site from PHP 5.6 to 7.0 (eventually to 7.2) I am seeing error notices like PHP Notice: Undefined index: productpage in ….. I know this it because the $_REQUEST can sometimes be empty depending on what data is passed back and when certain pages are loaded $productpage = mysqli_real_escape_string($con, $_REQUEST['productpage']); I also know that I could turn the error notice off or use isset to check $_REQUEST but I would prefer to use the ?? '' option to fix this issue. The problem is that when I add the ?? '' option to the above code the problem resolved itself but then moments later the same error on the same line reappeared in the error logs and I cant understand why. Can someone give me the correct example of where to place ?? '' in the above code so that I can rule out my potentially dodgy code as being the reason the error keeps reappearing.
Ok I have this code.. Code: [Select] <?php header("Expires: Thu, 17 May 2001 10:17:17 GMT"); // Date in the past header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header ("Pragma: no-cache"); // HTTP/1.0 session_start(); if (!isset($_SESSION['SESSION'])) require ( "../db_connection.php"); ?> <!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" /> <title>User Registration Form</title> </head> <body><center><br /><br /> <form name="registration" method="post" action="/php/user_registration/registered.php"> <table> <tr> <td>First Name:</td> <td><input type="text" name="fname" value="<?php $_SESSION['fname'] ?>" size="30" maxlength="50" /></td> </tr> <tr> <td>Last Name:</td> <td><input type="text" name="lname" value="<?php $_SESSION['lname'] ?>" size="30" maxlength="50" /></td> </tr> <tr> <td>E-Mail Address:</td> <td><input type="text" name="email" value="<?php $_SESSION['email'] ?>" size="30" maxlength="50" /></td> </tr> <tr> <td>Phone:</td> <td><input type="text" name="phone" value="<?php $_SESSION['phone'] ?>" size="30" maxlength="50" /></td> </tr> <tr> <td>City:</td> <td><input type="text" name="city" value="<?php $_SESSION['city'] ?>" size="30" maxlength="50" /></td> </tr> <tr> <td>Status:</td> <td> <select name="status" id="status"> <option>Pls. Select One <option value="single">Single <option value="relationship">In a Relationship <option value="complicated">It's Complicated </select> </td> </tr> <tr> <td>Province:</td> <td><input type="text" name="province" value="<?php $_SESSION['province'] ?>" size="30" maxlength="50" /></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="password" size="30" maxlength="50" /></td> </tr> <tr> <td>Confirm Password:</td> <td><input type="password" name="password2" size="30" maxlength="50" /></td> </tr> <tr> <td> <input type="reset" name="Submit2" value="Reset"></td> <td> <input type="button" name="Submit" value="Submit" onclick="SubmitForm(); return false;" ></td> </tr> </table> </form> </center> </body> </html> I'm not actually doing anything yet up there though I'm having an error on row "province". The error is Quote Undefined index: province in C:\wamp\www\php\user_registration\registration_form.php on line 75 I have tried almost everything and of all the rows I have there, that's the only one I'm having error at. I'm curious why I'm getting that error. Anyone? Sorry again , but it seems I still have some problem with my $_GET. Here is the error I get: Notice: Undefined variable: id in /opt/lampp/htdocs/EMC/customer-search.php on line 248 Notice: Undefined index: Page in /opt/lampp/htdocs/EMC/customer-search.php on line 255 Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /opt/lampp/htdocs/EMC/customer-search.php on line 302 And my code for second error: Code: [Select] $Per_Page = 2; // Per Page $Page = isset($_GET["Page"]); if (!$_GET["Page"]) { $Page=1; } I'm not really sure what's the problem with my first and third error so I will post the whole code he Code: [Select] <?php require_once("./include/fg_membersite.php"); require_once("./include/membersite_config.php"); $objConnect = mysql_connect("localhost","root","") or die(mysql_error()); $objDB = mysql_select_db("EMC"); $haha = $fgmembersite->UserEmail(); $_SESSION['storedemail']= $haha; $query4 = mysql_query("SELECT * FROM Register WHERE Email= '$haha'"); while ($row4 = mysql_fetch_array($query4)){ $id = $row4['ID']; } mysql_free_result($query4); ?> <html> <body> <form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>"> <table width="599" border="1"> <tr> <th>Keyword <input name="txtFirstName" type="text" id="txtFirstName" value="<?= isset($_GET["txtFirstName"]) ;?>"> <input name="txtLastName" type="text" id="txtLastName" value="<?= isset($_GET["txtLastName"]) ;?>"> <input name="txtCell" type="text" id="txtCell" value="<?= isset($_GET["txtCell"]) ;?>"> <? $opselect="SELECT DISTINCT Custgroup FROM UserAddedRecord"; $result = mysql_query ($opselect); while($nt=mysql_fetch_array($result)) { ?> <option><?= $nt[Custgroup]?></option>"; <? } ?> </select> <input type="submit" value="Search"> </tr> </table> </form> <? if (isset($_GET["txtFirstName"]) != "" || isset($_GET["txtLastName"]) != "" || isset($_GET["txtCell"]) != "" || isset($_GET["txtGroup"]) != "") { $objConnect = mysql_connect("localhost","root","") or die(mysql_error()); $objDB = mysql_select_db("EMC"); // Search By Name or Email $strSQL = "SELECT * FROM UserAddedRecord WHERE (FirstName LIKE '%".$_GET["txtFirstName"]."%' and LastName LIKE '%".$_GET["txtLastName"]."%' and Cell LIKE '%".$_GET["txtCell"]."%' and Custgroup LIKE '%".$_GET["txtGroup"]."%')"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $Num_Rows = mysql_num_rows($objQuery); $Per_Page = 2; // Per Page $Page = isset($_GET["Page"]); if (!$_GET["Page"]) { $Page=1; } $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) { $Num_Pages =1; } else if(($Num_Rows % $Per_Page)==0) { $Num_Pages =($Num_Rows/$Per_Page) ; } else { $Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages; } $strSQL .=" order by addedrec_ID DESC LIMIT $Page_Start , $Per_Page"; $objQuery = mysql_query($strSQL); ?> <table width="600" border="1"> <tr> <th width="50"> <div align="center">#</div></th> <th width="91"> <div align="center">CustomerID </div></th> <th width="98"> <div align="center">Name </div></th> <th width="198"> <div align="center">Email </div></th> <th width="97"> <div align="center">CountryCode </div></th> <th width="59"> <div align="center">Budget </div></th> <th width="71"> <div align="center">Used </div></th> </tr> <? while($objResult = mysql_fetch_array($objQuery)) { ?> <tr> <td><div align="center"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?=$objResult["addedrec_ID"];?>"></div></td> <td><div align="center"><?=$objResult["addedrec_ID"];?></div></td> <td><?=$objResult["FirstName"];?></td> <td><?=$objResult["LastName"];?></td> <td><div align="center"><?=$objResult["MobileCompany"];?></div></td> <td align="right"><?=$objResult["Cell"];?></td> <td align="right"><?=$objResult["Workphone"];?></td> </tr> <? } ?> </table> <br> Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page : <? if($Prev_Page) { if($_GET["txtFirstName"] == "") { echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtLastName=$_GET[txtLastName]'><< Back</a> "; } else { echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtFirstName=$_GET[txtFirstName]'><< Back</a> "; } } for($i=1; $i<=$Num_Pages; $i++){ if($i != $Page) { echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtFirstName=$_GET[txtFirstName]'>$i</a> ]"; } else { echo "<b> $i </b>"; } } if($Page!=$Num_Pages) { if($_GET["txtFirstName"] == "" && $_GET["txtLastName"] == "" && $_GET["txtCell"] == "") { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtGroup=$_GET[txtGroup]'>Next>></a> "; } else if($_GET["txtFirstName"] == "" && $_GET["txtLastName"] == "") { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtCell=$_GET[txtCell]'>Next>></a> "; } else if($_GET["txtFirstName"] == "" ) { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtLastName=$_GET[txtLastName]'>Next>></a> "; } else { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtFirstName=$_GET[txtFirstName]'>Next>></a> "; } } mysql_close($objConnect); } else { $strSQL = "SELECT * FROM UserAddedRecord WHERE user_id='$id'"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $Num_Rows = mysql_num_rows($objQuery); $Per_Page = 2; // Per Page $Page = isset($_GET["Page"]); if (!$_GET["Page"]) { $Page=1; } $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) { $Num_Pages =1; } else if(($Num_Rows % $Per_Page)==0) { $Num_Pages =($Num_Rows/$Per_Page) ; } else { $Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages; } $strSQL .=" order by id DESC LIMIT $Page_Start , $Per_Page"; $objQuery = mysql_query($strSQL); ?> <table width="600" border="1"> <tr> <th width="50"> <div align="center">#</div></th> <th width="91"> <div align="center">ID </div></th> <th width="198"> <div align="center">First Name </div></th> <th width="198"> <div align="center">Last Name </div></th> <th width="250"> <div align="center">Mobile Company </div></th> <th width="100"> <div align="center">Cell </div></th> <th width="100"> <div align="center">Workphone </div></th> <th width="100"> <div align="center">Group </div></th> </tr> <? echo "<form name='form1' method='post' action=''>"; while($objResult = mysql_fetch_array($objQuery)) { echo "<tr>"; echo "<td align='center'><input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"$objResult[addedrec_ID]\"></td>"; echo "<td>$objResult[addedrec_ID] </td>"; echo "<td>$objResult[FirstName]</td>"; echo "<td>$objResult[LastName] </td>"; echo "<td>$objResult[MobileCompany] </td>"; echo "<td>$objResult[Cell] </td>"; echo "<td>$objResult[WorkPhone] </td>"; echo "<td>$objResult[Custgroup] </td>"; echo "</tr>"; } echo "<td colspan='7' align='center'><input name=\"delete\" type=\"submit\" id=\"delete\" value=\"Delete\">"; if(isset($_POST['delete'])) // from button name="delete" { $checkbox = $_POST['checkbox']; //from name="checkbox[]" $countCheck = count($_POST['checkbox']); for($d=0;$d<$countCheck;$d++) { $del_id = $checkbox[$d]; $sql = "DELETE from UserAddedRecord where addedrec_ID = $del_id"; $result2=mysql_query($sql); } if($result2) { header('Location: customer-adddata.php'); } else { echo "Error: ".mysql_error(); } } echo "</form>"; ?> </table> <br> Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page : <? if($Prev_Page) { if($_GET["txtFirstName"] == "") { echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtLastName=$_GET[txtLastName]'><< Back</a> "; } else { echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtFirstName=$_GET[txtFirstName]'><< Back</a> "; } } for($i=1; $i<=$Num_Pages; $i++){ if($i != $Page) { echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtFirstName=$_GET[txtFirstName]'>$i</a> ]"; } else { echo "<b> $i </b>"; } } if($Page!=$Num_Pages) { if($_GET["txtFirstName"] == "" && $_GET["txtLastName"] == "") { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtCell=$_GET[txtCell]'>Next>></a> "; } else if($_GET["txtFirstName"] == "" ) { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtLastName=$_GET[txtLastName]'>Next>></a> "; } else { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtFirstName=$_GET[txtFirstName]'>Next>></a> "; } } mysql_close($objConnect); } ?> </body> </html> And one more error , when I tried to search data and typed some keywords in the textbox , three of the textbox will keep return me value "1" , I really tried to solve the error but still there....can anyone help me for this? Thanks in advanced. Hi guys. I got some problem with my code i got this error message : Notice: Undefined index: idmembers in C:\Users\su08danielc\Documents\Website\yts\edit_user.php on line 3 And don't know how to solve it This is my code edit_user.php Code: [Select] <?php include_once "../yts/inc/connect.php"; $id = $_GET['idmembers']; $username = $_POST['username']; $password = $_POST['password']; $email = $_POST['email']; $sql = "UPDATE Members SET username = '$username', password = '$password', email = '$email' WHERE Members . idmembers = '$id' LIMIT 1"; mysql_query($sql) or die ("Error: ".mysql_error()); echo "User Updated. <a href='test.php'> Return to Edit Info</a>"; ?> test.php Code: [Select] <?php include_once "../yts/inc/connect.php"; $sql = "SELECT * FROM Members WHERE idmembers = 1"; $results = mysql_query($sql); while ($row = mysql_fetch_array($results)){ $id = $row['idmembers']; $username = $row['username']; $password = $row['password']; $email = $row['email']; //we will echo these into the proper fields } mysql_free_result($results); ?> <html> <head> <title>Edit User Info</title> </head> <body> <form action="edit_user.php" method="post"> userid:<br/> <input type="text" value="<?php echo $id;?>" name="idmembers" disabled/> <br/> Username:<br/> <input type="text" value="<?php echo $username;?>" name="username"/> <br/> Password:<br/> <input type="text" value="<?php echo $password;?>" name="password"/> <br/> Email:<br/> <input type="text" value="<?php echo $email;?>" name="email"/> </br> <input type="submit" value="submit changes"/> </form> </body> </html> Hope you can help me out, Thanks in advance Notice: Undefined index: username in C:\wamp\www\LogInSystem\login.php on line 2 Notice: Undefined index: password in C:\wamp\www\LogInSystem\login.php on line 3 Help me to change this error Code: [Select] <?php $username = $_POST['username']; ERROR IS IN THIS LINE $password = $_POST['password']; ERROR IS IN THIS LINE if ($username&&$password){ $connect = mysql_connect ("localhost", "root","") or die ("could not connect"); mysql_select_db ("login") or die ("could not find db"); } else { die ("Please enter username and password!");} ?> Help me solve in error Notice: Undefined index: ch1 in C:\wamp\www\latest\library\bookdb.php on line 3 It comes when i uncheck any checkbox Thank U in advance Hello there,
I am coding Arduino micro controller, and intended to GET the data from server MySQL db through php to turn ON/OFF LED. I could able to GET the data from manually updated MySQL db value, even I could able to successfully change the data of MySQL db from micro controller POST method. But I am getting error when trying to change the MySQL db value from browser using online POST tool, Following is PHP code at server 8 $api_key_value ="XXXXXXXXX";//Sample 9 $api_key =""; 10 $status = ""; 11 $id =""; 12 13 if ($_SERVER["REQUEST_METHOD"] == "POST") { 14 $api_key = test_input($_POST["api_key"]); 15 if($api_key == $api_key_value) { $id = test_input($_POST["id"]); $status = test_input($_POST["status"]); // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } //$sql = "INSERT INTO led (status) //VALUES ('" . $status . "')"; $sql = "UPDATE led SET status='$status' WHERE id='$id'"; if ($conn->query($sql) === TRUE) { echo "New record created successfully"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } $conn->close(); } else { echo "Wrong API Key provided."; } } else { echo "No data posted with HTTP POST."; } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } Post Command: http://url/MySQL_POST.php?api_key=XXXXXXXXX&id=1&status=on Response/Error: Notice: Undefined index: api_key in <PATH>/MySQL_POST.php on line 14 Wrong API Key provided. Could be a basic issue, but I am very new to php coding and cannot solve this problem yet. Could someone please help? Thanks. Hey guys, Im getting an undefined index limit in the whole code. This is my code: <?php session_start(); $_SESSION['prev_page'] = $_SERVER['REQUEST_URI']; if (!session_is_registered('username')) { header("location:login.php"); } ?> <hr> <style type="text/css"> table.gridtable { color:#333333; border-width: 1px; border-color: #666666; border-collapse: collapse; width: 100%; } table.gridtable th { border-width: 1px; padding: 1px; border-style: solid; border-color: #666666; background-color: #dedede; } table.gridtable td { border-width: 1px; padding: 1px; border-style: solid; border-color: #666666; } .valid { border-width: 1px; padding: 1px; border-style: solid; border-color: #666666; background-color: transparent; } </style> </div> <div class="newsJustify"> <script type="text/javascript"> function checkall(delchk) { for (i = 0; i < delchk.length; i++) delchk[i].checked = true; } </script> <script type="text/javascript"> function uncheckall(delchk) { for (i = 0; i < delchk.length; i++) delchk.checked = false; } </script> <script language="JavaScript"> function loadPage(list) { location.href=list.options[list.selectedIndex].value } </script> <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("chat") or die(mysql_error()); if (isset($_POST['del'])) { for ($count = 0; $count < count($_POST["delchk"]); $count++) { $delete = $_POST["delchk"][$count]; $query = "DELETE FROM members_shouts WHERE id = '$delete'"; $result = mysql_query($query); if (!$result) { die("Error deleting accounts! Query: $query<br />Error: " . mysql_error()); } } } $data = mysql_query("SELECT * FROM `members_shouts`") or die(mysql_error()); $rows = mysql_num_rows($data); $page_rows = $_GET["limit"]; if ($page_rows == '') { // no double quotes (int) $page_rows = 5; } elseif ($page_rows == 'all') { $page_rows = $rows; } else { $page_rows = $_GET['limit']; /* validate this */ } if (!isset($_GET['pagenum'])) { $page = 1; } else { $page = (int) $_GET['pagenum']; } ?> <?php $max_pages = ceil($rows / $page_rows); $last = ceil($rows / $page_rows); $pagenum = ($page && $page > 0 && $page <= $last) ? $page : 1; $max = 'limit ' . ($pagenum - 1) * $page_rows . ',' . $page_rows; $data_p = mysql_query("SELECT * FROM members_shouts $max") or die(mysql_error()); ?> <?php $result = mysql_query("SELECT * FROM members_shouts"); if (mysql_num_rows($result) > 0) { ?> <span style="float: left;margin-left: 2px;"> <form> <select name="file" size="1" onchange="loadPage(this.form.elements[0])" target="_parent._top"> <option value="" <?php if ($_GET['limit'] == 0) { echo 'selected'; } ?>>Select Limit</option> <option value="?limit=9" <?php if ($_GET['limit'] == 9) { echo 'selected'; } ?>>9</option> <option value="?limit=15" <?php if ($_GET['limit'] == 15) { echo 'selected'; } ?>>15</option> <option value="?limit=30" <?php if ($_GET['limit'] == 30) { echo 'selected'; } ?>>30</option> <option value="?limit=all" <?php if ($_GET['limit'] == 'all') { echo 'selected'; } ?>>All</option> </select> </form> </span> <span style="float: right;margin-top: 2px;margin-right: 2px;"> <center> <?php if ($pagenum == 1) { } else { echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1&limit={$_GET['limit']}'>First</a> "; echo " | "; echo " "; $previous = $pagenum - 1; $current = $pagenum; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous&limit={$_GET['limit']}'>$previous</a> "; echo " | "; } echo "$pagenum"; if ($pagenum == $last || $last == 0) { } else { $next = $pagenum + 1; echo " | "; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next&limit={$_GET['limit']}'>$next</a> "; echo " "; echo " | "; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last&limit={$_GET['limit']}'>Last</a> "; } ?> </center> </span> <style type="text/css"> .clear2 { clear:both; height:0px; overflow:hidden; } </style> <div class="clear2"></div> <hr> <?php echo "<table class=\"gridtable\"> <thead> <tr> <th align=\"center\" scope=\"col\">user</th> <th align=\"center\" scope=\"col\">message</th> <th align=\"center\" scope=\"col\">when</th> <th align=\"center\" scope=\"col\">Delete?</th> </tr> </thead> <tbody>"; echo "<form name = 'myform' action='' method='post'>"; ?> <?php while ($info = mysql_fetch_array($data_p)) { echo "<tr align=\"center\">"; echo "<td class=\"valid\" >" . $info['user'] . "</td>"; echo "<td class=\"valid\" >" . $info['message'] . "</td>"; echo "<td>" . $info['when'] . "</td>"; echo '<td><input type="checkbox" id="delchk" name="delchk[]" value="' . $info['id'] . '" /></td>'; echo "</tr>"; } echo "</tbody>"; echo "</table>"; echo "<hr>"; echo "<input type='submit' name = 'del' value='Delete Selected'></form>"; echo "<input type='button' onclick='checkall(document.myform[\"delchk\"]);' value='Select All'>"; echo "<input type='button' onclick='uncheckall(document.myform[\"delchk\"]);' value='Deselect All'>"; echo "<hr>"; ?> <?php } else { // No rows were found ... echo '<center>No logged accounts.</center><hr>'; } ?> </hr> Im getting these errors and cant figure out at all how to fix them. the reason is, is that you can set the limit of rows to show on one page, and that is set by the variable limit it is used in 'localhost/admin?limit=5' That is 5 rows per page. There is also one called 'localhost/admin?limit=all' that is to show all the rows in one page. Im getting the errors: Code: [Select] Notice: Undefined index: limit in C:\Program Files (x86)\EasyPHP5.2.10\www\admin.php on line 176 Notice: Undefined index: limit in C:\Program Files (x86)\EasyPHP5.2.10\www\admin.php on line 179 Notice: Undefined index: limit in C:\Program Files (x86)\EasyPHP5.2.10\www\admin.php on line 90 Notice: Undefined index: limit in C:\Program Files (x86)\EasyPHP5.2.10\www\admin.php on line 130 Notice: Undefined index: limit in C:\Program Files (x86)\EasyPHP5.2.10\www\admin.php on line 135 Notice: Undefined index: limit in C:\Program Files (x86)\EasyPHP5.2.10\www\admin.php on line 140 Notice: Undefined index: limit in C:\Program Files (x86)\EasyPHP5.2.10\www\admin.php on line 145 Notice: Undefined index: limit in C:\Program Files (x86)\EasyPHP5.2.10\www\admin.php on line 150 I would be glad if someone could help me out by showing me how to set the limit when there is no GET used in the url.[/i] I added a column to my database with SQL as follows: ALTER TABLE comment_table ADD date_col Datetime NOT NULL; I try to insert into the database with the following PHP but nothing gets inserted. if(isset($_POST["submit"])) { $date_col = "test";//this will be DateTime later $name = $_POST["name"]; mysqli_query($connection, "INSERT INTO comment_table (name, date_col) VALUES ('$name', '$date_col')"); } $comsql = "SELECT * FROM comment_table"; $comres = mysqli_query($connection, $comsql); while($comr = mysqli_fetch_assoc($comres)){ ?> <div class="row"> <p>Name: <strong><?php echo $comr['name']; ?></strong>This is the code that is being pointed to as undefined index. <?php echo $comr['date_col']; ?> </p> <?php } ?> </div>
The data I'm using for the date_col column is varchar and it should be Datetime but I don't know if that's the reason for the error. I would like to set $date_col equal to a Datetime expression for testing purposes but the formatting I chose wasn't working either. Hey i keep getting undefined index error when i submit the editing page I cant figure out what the problem is I have checked if i have miss spelled anything from the mysql table and i haven't please help everything exist in mysql but still im getting this error and not letting me update it Notice: Undefined index: uruklink in D:\wamp\www\admin\edit.php on line 8 Notice: Undefined index: ketabsetlink in D:\wamp\www\admin\edit.php on line 9 <?php include "../configdb.php"; $id = $_GET['id']; if(isset($_POST['submit'])) { //global variables $uruklink = $_POST['uruklink']; $ketabsetlink = $_POST['ketabsetlink']; //run the query which adds the data gathered from the form into the database $result = mysql_query("UPDATE softlinks SET uruklink='$uruklink', ketabsetlink='$ketabsetlink' WHERE id='$id' ",$connect); echo "<b>Your Page have been edited successfully"; // echo "<meta http-equiv=Refresh content=2;url=index.php>"; } elseif($id) { $result = mysql_query("SELECT * FROM softlinks WHERE id='$id' ",$connect); while($row = mysql_fetch_assoc($result)) { $uruklink = $row['uruklink']; $ketabsetlink = $row['ketabsetlink']; ?> <h3>::Edit Page</h3> <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>?id=<?php echo $row['id']?>"> <input type="hidden" name="id" value="<?php echo $row['id']?>"> <input name="name" size="40" maxlength="255" value="<?php echo $uruklink; ?>"> <input name="footer" size="40" maxlength="255" value="<?php echo $ketabsetlink; ?>"> <input type="submit" name="submit" value="Submit"> <?php } } ?> Hi
I'm having a strange error with this code and i get it working properly
function CheckLoginInDB($username,$password) { if(!$this->DBLogin()) { $this->HandleError("Erro na ligação à Base de Dados!"); return false; } $username = $this->SanitizeForSQL($username); $nresult = mysql_query("SELECT * FROM utilizador WHERE utilizador = '$username'", $this->connection) or die(mysql_error()); // check for result $no_of_rows = mysql_num_rows($nresult); if ($no_of_rows > 0) { $nresult = mysql_fetch_array($nresult); $salt = $nresult['salt']; echo $salt; $encrypted_password = $nresult['password']; $hash = $this->checkhashSSHA($salt, $password); echo $hash; } $qry = "Select idutilizador, nome, email from utilizador where utilizador='$username' and password='$hash'"; $result = mysql_query($qry,$this->connection); if(!$result || mysql_num_rows($result) <= 0) { $this->HandleError("Erro: Utilizador ou password errados"); return false; } $row = mysql_fetch_assoc($result); $_SESSION['idutilizador'] = $row['idutilizador']; $_SESSION['name_of_user'] = $row['nome']; $_SESSION['email_of_user'] = $row['email']; return true; }This is my table Field Type Collation Null Key Default Extra Privileges Comment |