PHP - Array Diff Issue
Hey,
I am using array diff to find numbers in one array that are not in another array. Yet it returns a value which is in another array which is annoying... my array structure is: Code: [Select] Array( [0] => 06 [1] => 11) //this is TEMP Array( [0] => 2 [1] => 3 [2] => 5 [3] => 6 [4] => 6 [5] => 11 [6] => 11)//this is VALUES Now my returned difference should be: Code: [Select] [0] => 2 [1] => 3 [2] => 5 // all numbers not in TEMP But i get: Code: [Select] Array( [0] => 2 [1] => 3 [2] => 5 [3] => 6 [4] => 6)//6 IS in TEMP and should not appear 6 should not appear but it does....any one know why ? This is my code: $Temp = explode('+',$HandValue); $HighCard = array_diff($Values, $Temp); Any ideas? Similar TutorialsHi Everyone I have an older coded side that I am looking at for a friend, I need to add in a date diff colum into their existing index page. I can add using the following code onto the indivudually record page can't get it to work on the index. Any help is appreciated. Code on Individual page which works::: <HEAD> <? if($test['settlement_date']=="0000-00-00"){ $date1 = new DateTime($date_received); $date2 = new DateTime("now"); $interval = $date1->diff($date2); } else { $date1 = new DateTime($date_received); $date2 = new DateTime($settlement_date); $interval = $date1->diff($date2); } ?> </HEAD> <Body> <?php echo "".$interval->days."";?> </BODY> I was trying to add something similar but as it is a list I can't work out what I need to do. INDEX::: while($test = mysql_fetch_array($result)) { $complaint_id = $test['complaint_id']; echo"<tr>"; echo"<td class='standard_left'>".$test['complaint_id']."</td>"; echo"<td class='standard_left'>".$test['status']."</td>"; echo"<td class='standard_left'>".$test['LastName'].", ".$test['FirstName']."</td>"; echo"<td class='standard_left'><a href ='complaint_view.php?complaint_id=$complaint_id'>".$test['complainant']."</td>"; echo"<td class='standard_center'>".$test['date_received']."</td>"; echo"<td class='standard_center'>".$test['settlement_date']."</td>"; echo"<td class='standard_center'>".$test['interval->days']."</td>"; echo "</tr>"; I know it is old redundent code but if I can get this one colum working I would be happy. This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=344127.0 I copied and pasted the code below from php manual, http://www.php.net/manual/en/datetime.diff.php, I should have got the result of '2' as they did but I got the result of '6015'. I can't think why this would be. Any help appreciated. Code: [Select] $datetime1 = new DateTime('2009-10-11'); $datetime2 = new DateTime('2009-10-13'); $interval = $datetime1->diff($datetime2); echo $interval->format('%R%a days'); my directory on my mamp server looks like this; root/website/index.php I also have some files in a folder like this root/website/pages/files.php My include code is this include("functions.php"); When I try to include a file from the 'website' folder from a page in the 'pages' folder. It gives me errors that look like this. Warning: include(functions.php) [function.include]: failed to open stream: No such file or directory in /website/pages/contact.php on line 2 Warning: include() [function.include]: Failed opening 'functions.php' for inclusion (include_path='.:/Applications/MAMP/bin/php5.3/lib/php') in /Applications/MAMP/htdocs/website/pages/contact.php on line 2 That's what it looks like.. I can't get it working. Here's what I'm wanting to do: Number = 100 In a for loop take that number, 100, and break it down into 5 random numbers to equal 100. So the for loop would output something like this: 1. 32 2. 5 3. 18 4. 9 5. 36 Total = 100 Everytime the numbers would be different. I hope that explains it Thanks! So this is a simple code that finds out the difference between two dates and displays it in number of days. $date1=date_create("2013-03-15"); $date2=date_create("2013-12-12"); $diff=date_diff($date1,$date2); echo $diff->format("%R%a days"); // RESULT +272 days
My first question. Is it possible to remove the + sign in the result above? Second question. Is it possible to show "months" if it's greater than 30 days? And years if the days are greater than 365? How would I do this? I'm having problems populating my array... logically the code seems fine to me, any ideas? $query = mysql_query("SELECT ALU_7705_Statuses.StatusID, ALU_7705_Statuses.SiteID, Sites.SiteName FROM ALU_7705_Statuses LEFT JOIN Sites ON ALU_7705_Statuses.SiteID = Sites.SiteID WHERE ALU_7705_Statuses.Market = '$_SESSION[AllowedMarket]' AND ALU_7705_Statuses.CompleteIncomplete = 'Incomplete'", $a_link); $resultcount = mysql_num_rows($query); while ($row = mysql_fetch_assoc($query)) { $StatusID = ""; $SiteName = ""; $DateTimeOfStatus = ""; $Status = ""; $Statusor = ""; $Notes = ""; $subquery = mysql_query("SELECT Status_Reports.TechID, Status_Reports.DateTimeOfStatus, Status_Reports.Status, Status_Reports.Notes, Users.FirstName, Users.LastName FROM Status_Reports LEFT JOIN Users ON Status_Reports.TechID = Users.UserID WHERE Status_Reports.StatusID = '$row[StatusID]' ORDER BY StatusReportID DESC LIMIT 1", $a_link); while ($subrow = mysql_fetch_assoc($subquery)) { $StatusID = $row['StatusID']; $SiteName = $row['SiteName']; $DateTimeOfStatus = $subrow['DateTimeOfStatus']; $Status = $subrow['Status']; $Statusor = $subrow['FirstName'].' '.$subrow['LastName']; $Notes = $subrow['Notes']; echo ' <tr><td><a href="sitestatrep.php?StatusID='.$row["StatusID"].'">'.$row["SiteID"].'</a></td> <td>'.$row["SiteName"].'</td> <td>'.date("M j, Y g:i a", strtotime($subrow["DateTimeOfStatus"])).'</td> <td>'.$subrow["Status"].'</td> <td>'.$subrow["FirstName"].' '.$subrow["LastName"].'</td> <td>'.substr($subrow["Notes"], 0, 22).' ';if($subrow['Notes'] != ""){echo'...';}echo '</td> </tr>'; } for ($i=0;$i<$resultcount;$i++) { $resultsarray[$i]["StatusID"] = $StatusID; $resultsarray[$i]["SiteName"] = $SiteName; $resultsarray[$i]["DateTimeOfStatus"] = $DateTimeOfStatus; $resultsarray[$i]["Status"] = $Status; $resultsarray[$i]["Statusor"] = $Statusor; $resultsarray[$i]["Notes"] = $Notes; } } But when I print_r it, it filled all of the values with the last row of data... Hello I'm trying to get this working but i'm stuck I'm making a program who must define dates and time (hours) to a task So in the beginning i define: how many hours the task will have the week days the max hour per dayThe following code is working well except if the total is 20, and i have the sum of 18, the script allows to add more than 2 hours before stop the execution Example running the script
hours defined: 20 This is my code ( the problem should be inside foreach range code) define('INTERNAL_FORMAT', 'Y-m-d'); $startDate = "2020-09-01"; $start_date1 = strtotime("2020-09-01"); $endDate = strtotime("2021-06-30"); $horas = "20"; $sum = 0; $datediff = round(($endDate - $start_date1) / (60 * 60 * 24)) ; $res = array('01-01','02-25','04-10','04-12','04-25','05-01','06-10', '06-11', '08-15', '10-05', '11-01', '12-01', '12-08', '12-25'); $period = new DatePeriod( new DateTime('2021-03-27'), new DateInterval('P1D'), new DateTime('2021-04-16') ); $arr = array(); foreach ($period as $key => $value) { $arr[] = $value->format('m-d'); } $excluded_dates = array_merge($res, $arr); function isSegunda($date) { return date('w', strtotime($date)) === '1'; } function isTerca($date) { return date('w', strtotime($date)) === '2'; } function isQuarta($date) { return date('w', strtotime($date)) === '3'; } function isQuinta($date) { return date('w', strtotime($date)) === '4'; } function isSexta($date) { return date('w', strtotime($date)) === '5'; } // handle the excluded dates function isExcludedDate($internal_date) { global $excluded_dates; $str2 = substr($internal_date, 5); foreach($excluded_dates as $row){ return in_array($str2, $excluded_dates); } } // something to store months and days $cronograma = array(); $isSegunda = "1"; $isTerca = "2"; $isQuarta = ""; $isQuinta = ""; $isSexta = ""; $temposSegunda = "2"; $temposTerca = "4"; $temposQuarta = "4"; $temposQuinta = "4"; $temposSexta = "4"; foreach(range(0,$datediff) as $day) { $internal_date = date(INTERNAL_FORMAT, strtotime("{$startDate} + {$day} days")); $this_day = date(INTERNAL_FORMAT, strtotime($internal_date)); $this_month = date(INTERNAL_FORMAT, strtotime($internal_date)); if($isSegunda != null && $sum<$horas){ if ((isSegunda($internal_date)) && !isExcludedDate($internal_date)) { $cronograma[$this_month][] = $this_day; if($temposSegunda != null){ $cronograma[$this_month][] = $temposSegunda; } $sum += $temposSegunda; } } if($isTerca != null && $sum<$horas){ if ((isTerca($internal_date)) && !isExcludedDate($internal_date)) { $cronograma[$this_month][] = $this_day; if($temposTerca != null){ $cronograma[$this_month][] = $temposTerca; } $sum += $temposTerca; } } if($isQuarta != null){ if ((isQuarta($internal_date)) && !isExcludedDate($internal_date)) { $cronograma[$this_month][] = $this_day; if($temposQuarta != null){ $cronograma[$this_month][] = $temposQuarta; } } } if($isQuinta != null){ if ((isQuinta($internal_date)) && !isExcludedDate($internal_date)) { $cronograma[$this_month][] = $this_day; if($temposQuinta != null){ $cronograma[$this_month][] = $temposQuinta; } } } if($isSexta !=null){ if ((isSexta($internal_date)) && !isExcludedDate($internal_date)) { $cronograma[$this_month][] = $this_day; if($temposSexta != null){ $cronograma[$this_month][] = $temposSexta; } } } } $soma = 0; echo "hours defined: ".$horas; print "<br>"; foreach($cronograma as $month => $days) { $dias = $days[0]; $tempos = $days[1]; echo "Data: ".$dias." -Hours:".$tempos; print "<br>"; $soma+= $days[1]; } echo "Total: ".$soma; Any help?
Thanks Hey guys! I am trying to create a script to "promote" all my members at once based on some forum measurements. Here is my code (pastebin).
I don't know what is wrong. The page is blank and won't even load. Please help.
http://pastebin.com/aZeKq1Zw
Note: This is within the vBulletin 4.2.2 framework.
Hey I have an array comparison which returns values in an array but then i need to change values that are 1 in the array to 14 so currently i use a loop but i get undefined offset issues. How can i change it to work properly with error? This is my current attempt: $HC = array_diff($Values,$Temp); $i = 0; foreach($HC as $value) { if($HC[$i] == 1) { $HC[$i] = 14; } $i++; } Generally I am able to help my self on the forums. But, this one has me stumped. I've done it before and I don't remember it being this hard. The array looks something like so $users['id'] = '00001','00002','0003' $users['jobs'] = '22','322','112' $users['connected'] = '12','210','89' $users['percent'] = '54','65','89' I've used so much different things to try and take those, keep the data together (index 0 might be moved to 2, but all values from 0 are moved to 2) and sort by 'percent'. So I can display the person that has the highest percentage first. Basically the data was originally a CSV that is now in a database and is pulled, percentages calculated and then displayed. But the order is off. There is a bunch more data then show but I'm using PHP to do all the math for adding up jobs, seeing whats connected right and then coming up with a percentage, sticking it all in an array so I can sort it; but for some reason I cannot remember how I've done this before. Hello Can somepne help me with this issue I have a query who is returning some records ID disciplina moduloUfcd idcpDisciplinas anoTurma
58, Comunicação Visual, 8599, 49, 11 60, Comunicação Visual, 134, 49, 10 When i trying to put this into an array with just one line (merge all with number 49 (idcpDisciplinas) and (anoTurma) 11) i can't get the desired output
My sql query is this one select c.idPlan, cD.disciplina, cM.moduloUfcd, p.Nome, t.Turma, a.Ano, c2.curso, c.validCron, c.cronograma, c.dataLimite, c.idProfessor,cM.horas,cM.tempos, c.pdfCronograma, c2.curso, cM.discModulo, cM.idcpDisciplinas, cM.ano as anoTurma from cpDiscProfessores c inner join cpDisciplinas cD on c.idcpDisciplinas = cD.idCpDisciplinas inner join cpModulos cM on c.idCpModulos = cM.idCpModulos inner join professores p on c.idProfessor = p.idProfessor left join turmas t on c.idTurma = t.idTurma inner join anosescolares a on c.idAnoEscolar = a.idAnoEscolar left join cursos c2 on c.idCursos = c2.idCursos where a.Estado = 1;
And in php what i have is this $result = $stmt->fetchAll(PDO::FETCH_ASSOC); $final = array(); $json = array(); foreach ($result as $row) { $moduloUfcd= $row['moduloUfcd']; if (!isset($moduloUfcd[$moduloUfcd])) { $horas= $row['horas']; $final[$moduloUfcd]['idPlan'] = $row['idPlan']; $final[$moduloUfcd]['disciplina'] = $row['disciplina']; $final[$moduloUfcd]['Nome'] = $row['Nome']; $final[$moduloUfcd]['Turma'] = $row['Turma']; $final[$moduloUfcd]['anoTurma'] = $row['anoTurma']; $final[$moduloUfcd]['curso'] = $row['curso']; $final[$moduloUfcd]['validCron'] = $row['validCron']; $final[$moduloUfcd]['cronograma'] = $row['cronograma']; $final[$moduloUfcd]['dataLimite'] = $row['dataLimite']; $final[$moduloUfcd]['idProfessor'] = $row['idProfessor']; $final[$moduloUfcd]['pdfCronograma'] = $row['pdfCronograma']; $final[$moduloUfcd]['discModulo'] = $row['discModulo']; $final[$moduloUfcd]['idcpDisciplinas'] = $row['idcpDisciplinas']; $final[$moduloUfcd]['moduloUfcd'] = array(); } $final[$moduloUfcd]['moduloUfcd'][] = $row['moduloUfcd']; $final[$moduloUfcd]['horas'][] = $row['horas']; $final[$moduloUfcd]['tempos'][] = $row['tempos']; } foreach ($final as $moduloUfcd => $cron) { $json[] = $cron; } echo json_encode($json); What it gives is : [ { idPlan: "60", disciplina: "Comunicação Visual", Nome: "XXXXXXXXX", Turma: "11ºO", anoTurma: "11", curso: "Técnico de Audiovisuais", validCron: "-1", cronograma: "0", dataLimite: "2020-10-30", idProfessor: "168", pdfCronograma: "/XXXXX/pdf/profissionais/cronogramas/Cronograma -Técnico de Audiovisuais-8599.pdf", discModulo: "8599", idcpDisciplinas: "49", moduloUfcd: [ "8599" ], horas: [ "25" ], tempos: [ " 34 " ] } ]
Hi All, I'm running trying to add key and values to an array on multiple pages, but it seems to override the array each time I add variables on the next page, even though the keys are different. Each page has something like this: Code: [Select] <label class="yes"><input type="radio" name="form_field[<?php echo "number".$f1; ?>]" value="0" > Yes</label> <label class="no"><input type="radio" checked="checked" name="form_field[<?php echo "number".$f1; ?>]" value="1" > No</label> <label class="unsure"><input type="radio" name="form_field[<?php echo "number".$f1; ?>]" value="2" > Unsure</label> I then collect it as well as other page variables with: Code: [Select] session_start(); foreach($_POST as $name => $value) { $_SESSION[$name] = $value; } on all following pages. But rather than adding to the array it writes over it each time. Any ideas on what's going wrong here. Should the array simply be able to continue to collect the keys or do I need to do something else? Thanks. I have an array which will be below. The array is being built from an XML file, the problem is I need to extrapolate data from it.
I am having trouble with looping through the array properly.
The output should be something like this:
Beth's state is 0 (Where Beth's is the name and 0 is the state)
Clint's state is 0
Array ( [0] => Array ( [did] => 216616014153767704 [known] => 1 [lock] => 0 [state] => 0 [level] => 100 [node] => 30 [port] => 0 [nodetype] => 16386 [name] => Beth's [desc] => LED [colorid] => 1 [type] => multilevel [rangemin] => 0 [rangemax] => 99 [power] => 0 [poweravg] => 0 [energy] => 0 [score] => 0 [productid] => 1 [prodbrand] => TCP [prodmodel] => LED A19 11W [prodtype] => LED [prodtypeid] => 78 [classid] => 2 [class] => [subclassid] => 1 [subclass] => [other] => ) [1] => Array ( [did] => 216616014154116936 [known] => 1 [lock] => 0 [state] => 0 [level] => 100 [node] => 30 [port] => 0 [nodetype] => 16386 [name] => Clint's [desc] => LED [colorid] => 1 [type] => multilevel [rangemin] => 0 [rangemax] => 99 [power] => 0 [poweravg] => 0 [energy] => 0 [score] => 0 [productid] => 1 [prodbrand] => TCP [prodmodel] => LED A19 11W [prodtype] => LED [prodtypeid] => 78 [classid] => 2 [class] => [subclassid] => 1 [subclass] => [other] => ) ) hey there I have an issue when I am inserting an array into the database. When I run the insert statements the records get inserted but it is sometimes one less record than is in the table and sometimes even less. for example if I have 5 records it only inserts the first 4. This is confusing because when I echo out the statement in the loop it shows all 4 insert statements. my loop for inserting looks like this: if(isset($_SESSION['cushArray'])){ foreach($_SESSION['cushArray'] as $key => $value){ $getCushSKU = "SELECT SKU FROM Cushion WHERE Name = '".$value['Cushion']."'"; //echo $getCushSKU; $resultGetCushSKU = mysql_query($getCushSKU); $getResultGetCushSKU = mysql_fetch_assoc($resultGetCushSKU); //echo $getResultGetCushSKU['SKU']; $getFabricSKU = "SELECT SKU FROM Fabric WHERE Name = '".$value['Fabric']."'"; $resultGetFabricSKU = mysql_query($getFabricSKU); $getResultGetFabricSKU = mysql_fetch_assoc($resultGetFabricSKU); if($_SESSION['cushArray'][$i]["ContWeltFabric"] != "N/A"){ $getWeltFabricSKU = "SELECT SKU FROM Fabric WHERE Name = '".$value['ContWeltFabric']."'"; $resultGetWeltFabricSKU = mysql_query($getWeltFabricSKU); $getResultGetWeltFabricSKU = mysql_fetch_assoc($resultGetWeltFabricSKU); }else{ $getResultGetWeltFabricSKU = "N/A"; } $sqlCush = "INSERT INTO OrdersCushion(OrderID, ProductSKU, FabricSKU, WeltFabricSKU, Quantity, ButtonColor, ZipperColor, Fill) VALUES('".$getOrderIDNum['OrderID']."', '".$getResultGetCushSKU['SKU']."', '".$getResultGetFabricSKU['SKU']."', '".$getResultGetWeltFabricSKU['SKU']."', '".$value['Quantity']."', '".$value['Button']."', '".$value['Zipper']."', '".$value['Fill']."') "; //echo $sqlCush; $resultCush = mysql_query($sqlCush); } } any help is much appreciated Hi,
I'm currently passing an array of values to be updated in my database, but am struggling on the best way to escape the quotation marks around the NOW statement below, as understand this will only work without them. This is what is being passed to the DB which does not currently work. I'm seeking some help to find the best way to remove the "" from around the NOW statement, but retain it in the array structure which i believe needs the '' to understand its a value. UPDATE staff SET staff_last_login="NOW()" WHERE staff_id="1" array('staff_last_login'=>'NOW()')My question is - whats the best way to escape this? I understand forward slashes can sometimes be used, and double quotes - but feel like i have exhausted all my known options. Any help much appreciated. MoFish Hey basically i'm working on a multi checkbox way to delete messages stored in "crew_messages", i'm getting the error message "Unknown column 'Array' in 'where clause'" from the following code and i'm unsure as to why Code: [Select] if (isset($_POST["submit2"]) == "DELETE SELECTED") { for($i=0;$i<count($_POST["chkColor"]);$i++) { if(trim($_POST["chkColor"][$i]) != "") { $rawr = $_POST['chkColor']; $sql = "DELETE FROM crew_messages WHERE id = $rawr"; mysql_query($sql) or die(mysql_error()); } } } the check box itself Code: [Select] <input type="checkbox" name="chkColor[]" value="27"> any clues? cheers For this example, $row2['author'] = "1" $user = 'user'.$row2['author']; if (!isset($$user)){ $result = $connector->query('SELECT * FROM users WHERE ID = '.$row2['author']); $$user = $connector->fetchArray($result); } echo '<a href="user.php?user='.($$user['ID']).'">'.$$user.'</a></p>'; The problem is it is a weird variable that also has an array, but when i use echo $$user['ID']; It errors out saying Notice: Quote Undefined variable: u So I am wondering how to word it to set the variable up properly, and how to call items in the array. Thanks in advance Okay, this is getting on my nerves now, my head is throbbing probably just need a break from it all now. I'm currently getting the following message; Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in C:\xampp\htdocs\duff3\test3.php on line 25 Can anyone figure out and explain why this isn't working for me, I believe I am calling the function correctly and then putting the result into a while loop. Code: [Select] <?php function getPageContent($selectedPage) { $sql = "SELECT * "; $sql .= "FROM tbl_pages "; $sql .= "WHERE tbl_pages.pageCategoryId = ".$selectedPage." "; $sql .= "AND active = 1 "; $sql .= "LIMIT 1"; $result = mysql_query($sql) or die ("Error in page sql query:". $sql); return $pageSet; } ?> Code: [Select] <?php require_once ''.$_SERVER['DOCUMENT_ROOT'].'/duff3/commonResources/dbConnection/dbQueryClass.php'; ?> <?php #FUNCTIONS IS A TEMP FILE UNTIL OO PHP COMES INTO PLAY require_once ("commonResources/includes/functions.php"); # if page isn't set then set it to default. if(isset($_GET["page"])) { $selectedPage = $_GET["page"]; } else { $selectedPage = 1; } #call function to select all page $pageSet = getPageContent($selectedPage); ?> <!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> <title> <?php while ($row = mysql_fetch_array($pageSet)) { # Start while loop echo $row["pageTitle"]; ?> </title> <link rel="shortcut icon" href="commonResources/images/container/favicon.ico" /> <link rel="stylesheet" type="text/css" href="<?php $_SERVER["DOCUMENT_ROOT"] ?>/duff3/commonResources/css/style.css" /> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" /> <!-- PUT COMMON JAVASCRIPT FILES IN AN INCLUDE 05/05/2011 --> <script type="text/javascript" src="commonResources/javaScript/jQuery.js"></script> <script type="text/javascript" src="commonResources/javaScript/jQueryTest/menu.js"></script> <?php require_once ("".$_SERVER["DOCUMENT_ROOT"]."/duff3/commonResources/includes/tinymce.php"); ?> </head> <body> <div id="viewContainer"><!--OPEN DIV FOR VIEW CONTAINER --> <div id="headerContent"><!--OPEN DIV FOR HEADER CONTENT --> <div class="logoContent"><!--OPEN DIV FOR LOGO CONTAINER --> <a href="index.html"><img src="<?php $_SERVER["DOCUMENT_ROOT"] ?>/duff3/commonResources/images/container/logo.png" alt="Hannah Jane Duff" longdesc="Hannah Jane Duff Home Link" /></a> </div><!--CLOSE DIV FOR LOGO CONTAINER --> </div><!--CLOSE DIV FOR HEADER CONTENT --> <!-- TEMP TAKE OUT AND PUT INTO HEADER AREA --> <div id="mainContent"><!--OPEN DIV FOR MAIN CONTENT--> <div class="centreContent"><!--OPEN DIV FOR CENTRE CONTENT--> <div id="menuContent"><!--OPEN DIV FOR MENU CONTENT--> <div id="menu"> <ul class="menu"> <li><a href="index.html" class="main"><span>Home</span></a></li> <li><a href="" class="main"><span>bio</span></a> <div><ul> <li><a href=""><span>violin</span></a></li> <li><a href=""><span>piano</span></a></li> <li><a href=""><span>singing</span></a></li> <li><a href="" class="parent"><span>teaching</span></a> <div><ul> <li><a href="" class="parent"><span>aberdeen</span></a> <div><ul> <li><a href="#"><span>aberdeen 1</span></a></li> </ul></div> </li> <li><a href="" class="parent"><span>bradford</span></a> <div><ul> <li><a href=""><span>bradford 1</span></a></li> </ul></div> </li> <li><a href="" class="parent"><span>leeds</span></a> <div><ul> <li><a href=""><span>leeds 1</span></a></li> </ul></div> </li> </ul></div> </li> <li><a href="" class="parent"><span>influences</span></a> <div><ul> <li><a href=""><span>classical</span></a></li> <li><a href=""><span>folk</span></a></li> </ul></div> </li> <li><a href="" class="parent"><span>other</span></a> <div><ul> <li><a href=""><span>folk′d</span></a></li> <li><a href=""><span>string quaret</span></a></li> </ul></div> </li> </ul></div> </li> <li><a href="" class="main"><span>publicity</span></a> <div><ul> <li><a href="" class="parent"><span>news</span></a> <div><ul> <li><a href=""><span>may 2011</span></a></li> <li><a href=""><span>march 2011</span></a></li> </ul></div> </li> <li><a href=""><span>gallery</span></a></li> <li><a href=""><span>other</span></a></li> </ul></div> </li> <li><a href="" class="main"><span>recordings</span></a> <div><ul> <li><a href=""><span>all</span></a></li> <li><a href=""><span>new york dolls</span></a></li> <li><a href=""><span>classical</span></a></li> </ul></div> </li> <li><a href="" class="main"><span>contact</span></a></li> </ul></div> </div><!--CLOSE DIV FOR MENU CONTENT--> <div class="paraBlock"><!--OPEN DIV FOR PARA BLOCK --> <p><?php echo $row["pageContent"]; ?></p> </div><!--CLOSE DIV FOR PARA BLOCK--> <div class="clearArea"><!--OPEN DIV FOR CLEAR AREA--> </div><!--CLOSE DIV FOR CLEAR AREA--> </div><!-- CLOSE DIV FOR CENTRE CONTENT--> </div><!--CLOSE DIV FOR MAIN CONTENT--> <div id="footerContent"><!--OPEN DIV FOR FOOTER CONTENT--> <div class="leftFooter"><!--OPEN DIV FOR LEFT FOOTER--> © <?php echo date(Y); ?> All Rights Reserved | Design by <a href="http://www.innovationation.co.uk/">Innovationation UK</a> </div><!--CLOSE DIV FOR LEFT FOOTER--> <div class="rightFooter"><!--OPEN DIV FOR RIGHT FOOTER--> <a href="">Copyright | </a> <a href="">Disclaimer | </a> <a href="">Privacy Policy </a> <a href="">Terms of Use | </a> <a href="">Site Map | </a> <a href="loginArea/login.php">Admin</a> </div><!--CLOSE DIV FOR RIGHT FOOTER--> </div><!--CLOSE DIV FOR FOOTER CONTENT--> <?php } ?> </div><!--CLOSE DIV FOR VIEW CONTAINER--> </body> </html> There's probably an obvious reason but I can't seem to find it... I start with the $_POST array, received from a form: Code: [Select] array(9) { ["Name"]=> string(3) "KTN" ["SQLServer"]=> string(24) "10.6.11.20\VSQLI028,1433" ["Username"]=> string(2) "GF" ["Password"]=> string(2) "GF" ["MasterDB"]=> string(11) "GFMaster_KN" ["Version"]=> string(3) "4.9" ["Prod"]=> string(1) "1" ["Monitored"]=> string(1) "0" ["button"]=> string(38) "updateColumnName=EnvironmentID;Value=1" } I get the button value from the array, and unset the button array value. Code: [Select] function load_POST($name) { //returns value and removes it from $_POST array. returns NULL if not existing. $debug = 0; if ( $debug == 1 ) { $backtrace = backtrace(); echo __FUNCTION__."()"; echo " <i>called by ".basename($backtrace[1]['file'])."</i><br/>\n"; } $post = NULL; if( array_key_exists($name, $_POST) ) { $post = urldecode($_POST[$name]); if ( $debug == 1 ) { echo "post $name, value: $post<br/>\n"; } } else { if ( $debug == 1 ) { echo "post $name: doesn't exist<br/>\n"; } } unset($_POST[$name]); return $post; } $_POST is now: Code: [Select] array(8) { ["Name"]=> string(3) "KTN" ["SQLServer"]=> string(24) "10.6.11.20\VSQLI028,1433" ["Username"]=> string(2) "GF" ["Password"]=> string(2) "GF" ["MasterDB"]=> string(11) "GFMaster_KN" ["Version"]=> string(3) "4.9" ["Prod"]=> string(1) "1" ["Monitored"]=> string(1) "0" } Then I create the object to assign the values to: Code: [Select] object(Environment)#1 (9) { ["EnvironmentID"]=> NULL ["Name"]=> NULL ["SQLServer"]=> NULL ["Username"]=> NULL ["Password"]=> NULL ["MasterDB"]=> NULL ["Version"]=> NULL ["Prod"]=> int(0) ["Monitored"]=> int(0) } So far so good Then, for each remaining $_POST value, I update the Object accordingly: First one, parametername: Name, parameter: KTN Code: [Select] object(Environment)#1 (10) { ["EnvironmentID"]=> NULL ["Name"]=> string(3) "KTN" ["SQLServer"]=> NULL ["Username"]=> NULL ["Password"]=> NULL ["MasterDB"]=> NULL ["Version"]=> NULL ["Prod"]=> int(0) ["Monitored"]=> int(0) ["ColumnName=EnvironmentID;Value=1"]=> object(stdClass)#3 (1) { ["ColumnName"]=> string(1) "1" } } And there we have the problem, for some reason the button value is added to the object somehow... Any ideas? Thanks in advance! |