Search the Community
Showing results for tags 'undefined variable'.
-
Having issues with an in book problem. I keep getting and "Undefined variable" Notice on the line that starts with "while ($currField != NULL) {" I am assuming it has something to do with the not NULL but I have no clue on this one folks. <?php error_reporting(E_ALL); ini_set('display_errors', 'on'); $record = "jdoe:8W4dS03a39Yk2:1463:24:John Doe:/home/jdoe:/bin/bash"; $passwordFields = array( "login name", "optional encrypted password", "numerical user ID", "numerical group ID", "user name or comment field", "user home directory", "optional user command interpreter"); $fieldIndex = 0; $extraFields = strtok($record, ":"); while ($currField != NULL) { if ($fieldIndex < count($passwordFields)) echo "<p>The {$passwordFields[$fieldIndex]} is <em>$currField</em></p>\n"; else { ++$extraFields; echo "<p>Extra Field # $extraFields is <em>$currField</em></p>\n"; } $currField = strtok(":"); ++$fieldIndex; } ?>
-
I have 2 issues happening, first one I need to get resolved is, line 60 is giving me a 'Notice: Undefined variable: delete'. This codes had multi issues but was able to resolve all but this one and my table not filling in with the data from my database. If you need any other info please let me know, Again I am new at this. <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete value="delete"></td> </tr> <?php // Check if delete button active, start this *line 60* -----> if ($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "DELETE FROM $tbl_name WHERE id='$del_id'"; $result = mysqli_query($sql); } // if successful redirect to delete_multiple.php if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">"; } } mysqli_close($con); ?>
- 1 reply
-
- php
- undefined variable
-
(and 1 more)
Tagged with:
-
Why does php show undefined variable? I researched and found out that if the variables aren't set then they will likely show undefined variable. However, I used the isset function to check if the variable is undefined and if it is then set it to $varaible ="" . That didn't work and then later i tried $variable = NULL. What should I do Can you please see the code and tell me what shall i do. Thanks a million <?php require_once("includes/connection.php")?> <?php require_once("includes/function.php") ?> <?php require_once("includes/header.php") ?> <?php if(isset($_GET['subj'])){ $sel_subj = NULL; $sel_subj = $_GET['subj']; } elseif (isset($_GET['page'])){ $sel_page = NULL; $sel_page = $_GET['page'] ; } else { $sel_subj= NULL; $sel_page =NULL; } ?> <table id = "structure" > <tr> <td id = "navigation" > <ul class= "subjects" > <?php $subject_set = get_all_subjects(); while ($subject = mysql_fetch_array($subject_set)){ // <a href = "content.php?subj=1" > if ($sel_subj == $subject["id"]){ echo "<li class = \"selected\" "; }else{ echo "<li> "; } "<a href = \"content.php?subj=" . urlencode($subject["id"]) . "\">" . $subject["menu_name"]. "</a></li>" ; $page_set = get_pages_for_subjects( $subject["id"] ) ; echo " <ul class = \"pages\"> "; while ($page = mysql_fetch_array($page_set)){ echo "<li><a href = \"content.php?page=" . urlencode($page["id"]) . "\">" . $page["menu_name"] . "</a></li>" ; } echo "</ul>" ; } ?> </ul> </td> <td id= "page" > <h1> Main Area To Get Your Information </h1> <?php echo $sel_subj ; ?> <br/> <?php echo $sel_page ; ?> <br/> </td> </tr> </table> <?php include ("includes/footer.php") ?> The variable im refering to is $sel_subj and $sel_page at the top of the code. Here is an attachment of the error
- 2 replies
-
- php
- undefined variable
-
(and 1 more)
Tagged with:
-
Hi - I have a website that was working previously and then all of a sudden, I got these messages on the front page of the website and can o longer log in to Wordpress at all. Error 1 and 2 are attached in the file. They repeat themselves at the top of the front page. Nothing is working now. I don't know how to fix this or where to start. One looks like it is paypal advanced. Do I need to reload the plug in? The other one - no clue. Thanks in advance!!! RYT errors.pdf
-
Hey, I'm trying to code a code a user has to input before continuing the registering to my site, for example what I'm trying to do is this: 1 + 3 = 5. So it will randomly give 2 numbers which then the user has to submit the right answer to carry on although its saying I have a undefined variable, which the variable I'm using is defined. My code: if ($Code){$NumberOne = 1;$NumberTwo = 50;$RandomNum = rand($NumberOne, $NumberTwo);$RandomNum1 = rand($NumberTwo, $NumberOne);$Output = $RandomNum;$Output1 = $RandomNum1; // Doing the sum..if ($Output >= 1 || $Output1 >= 1){$Sumfin = $Output + $Output1;$Eq = $SumFin; if ($Sumfin != $Eq){$Message = "Incorrect number adding";$Succ = "no";}elseif ($Sumfin == $Eq){$Succ = "yes";} }elseif ($Output > 50 || $Output1 > 50){$Message = "Something went wrong.";$Succ = "no";}} How I'm out putting it: <td width="50%">Secruity Code:</td><td width="50%"><?php echo $Output;?> + <?php echo $Output1; ?>: <input type="text" name="Code" id="Scode" class="TextInput" maxlength="3"></td> So what can I do here differently to remove the error? Thanks for your help
-
hi bin getting this undefined variable notice and i was just wondering what it meant, because everything is working the way i want it to but getting this notice at the bottom is getting a bit stupid ( ! ) Notice: Undefined variable: errors in C:\wamp\www\AddLeads\addeadstemplate.php on line 99Call Stack#TimeMemoryFunctionLocation10.0000158288{main}( )..\addeadstemplate.php:0 this is the section its in <?php if (count($errors)==0) { $con = mysqli_connect("localhost","root","","nib"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql="INSERT INTO tbl_club_contacts (CompanyName, FirstName, Address1, Address2, Area, City) VALUES ('$_POST[companyname]','$_POST[firstname]','$_POST[address1]','$_POST[address2]','$_POST[area]','$_POST[city]')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); echo "record added"; } mysqli_close($con); } // end if $errors == 0 ?> </form> </body> </html>
-
I've narrowed down my problem to this function... The page won't load, I suspected it was because it was stuck in a loop, but I couldn't see why, checking the error log confirmed this, as there were hundreds of errors for an undeclared variable.... I can't figure out why it is stuck in this loop, and I can't get the undeclared variable to go away, I even renamed it and it is still saying the old name of the variable is undeclared even though it isn't mentioned in the code anywhere I've renamed it.... Can anyone spot what is causing me grief? The only thing that would make sense would be if I wasn't updating the files when I uploaded them, but I am completely certain that I am... error log: code: while ($i<=14) { if($replacement_company_PartNo[$i] = NULL) { //this isn't an item from the database, simply print the description $replacement_Description //write details to new delivery note via 'delnoteitems' $sql = "INSERT INTO `companyorders`.`delnoteitems`(`deliverNote`, `itemDesc`, `itemQuantity`, `itemNotes`, `company_PartNo`) VALUES ('$deliverNote', '$replacement_Part_Name[$i]', '$replacement_Quantity[$i]', '$replacement_Description[$i]', '$replacement_company_PartNo[$i]');" ; $result = mysql_query($sql); if(!$result) {echo "$sql<br>sql error! code: DL4-A031-$i. This isn't an item from the database, skipping write to 'fullnotestock'; however, 'delnoteitems' could not be written to. Round $i."; exit;} } else { //this is an item from the database, the stock listings must be updated as the item is listed onto the delivery note //write details to new delivery note via 'delnoteitems' $sql = "INSERT INTO `companyorders`.`delnoteitems`(`deliverNote`, `itemDesc`, `itemQuantity`, `itemNotes`, `company_PartNo`) VALUES ('$deliverNote', '$replacement_Part_Name[$i]', '$replacement_Quantity[$i]', '$replacement_Description[$i]', '$replacement_company_PartNo[$i]');" ; $result = mysql_query($sql); if(!$result) {echo "$sql<br>sql error! code: DL4-A032-$i. This is an item from the database, havent yet attempted to write to 'fullnotestock'; failed on 'delnoteitems' which could not be written to. Round $i."; exit;} //update the stock listing in 'fullstocklist' $sql = "UPDATE `fullstocklist` SET `Stock`='$stockfromdatabase[$i]' WHERE `company_PartNo`='$replacement_company_PartNo[$i]';" ; $result = mysql_query($sql); if(!$result) {echo "$sql<br>sql error! code: DL4-A033-$i. This is an item from the database, havent yet attempted to write to 'fullnotestock'; failed on 'delnoteitems' which could not be written to. Round $i."; exit;} } $i++; }
- 3 replies
-
- php
- undefined variable
-
(and 2 more)
Tagged with:
-
Notice: Undefined variable: to in C:\xampp\htdocs\PDO\inbox.php on line 146 line 146 print" <td style=\"width:70%\"><input type=\"text\" name=\"to\" maxlength=\"50\" style=\"width:200px\" value=\"{$to}\" /></td>"; $errors = array(); if (!empty($_POST['submit'])) { $to = isset($_POST['to']) ? htmlspecialchars($_POST['to'], ENT_QUOTES) : ''; // OTHER SIMILAR THINGS // if (empty($to)) { $errors[] = "Please enter the username of who you wish to send this message to!"; } // OTHER ERRORS // } if (!empty($_POST['submit']) && empty($errors)) { // UPDATE DATABASE THING // }