[Solved] Check if array has [0][1][2] or just single item

[ad_1] You can test whether CustomCategory contains is an indexed or associative array by checking for an element with index 0. If not, you can wrap the contents in an array and then do your foreach loop. $customCategory = $obj[“Store”][“CustomCategories”][“CustomCategory”]; if (!$customCategory[0]) { $customCategory = array($customCategory); } foreach ($customCategory as $category => $val) { … … Read more

[Solved] put blank value instead of null in array value php [duplicate]

[ad_1] PHP Code (modified from Replacing empty string with nulls in array php): $array = array( ‘first’ => NULL, ‘second’ => NULL ); echo json_encode($array); $array2 = array_map(function($value) { return $value === NULL ? “” : $value; }, $array); // array_map should walk through $array echo json_encode($array2); Output: {“first”:null,”second”:null} {“first”:””,”second”:””} 1 [ad_2] solved put blank … Read more

[Solved] php GET variable is empty [closed]

[ad_1] $GET should be $_GET since it is a superglobal. That is the actual name of the get parameters array. Reference: http://php.net/manual/en/language.variables.superglobals.php 1 [ad_2] solved php GET variable is empty [closed]

[Solved] Unable to insert data in MySQL database [duplicate]

[ad_1] I suggest using PDO or MYSQLi because MySQL_ is depreciated. Not only that, you’re not escaping your values and are exposing yourself to some issues such as MySQL injection $pdo = new PDO(“mysql:host=localhost;dbname=db”,”root”,”password”); $query = $pdo->prepare(“INSERT INTO `metabase` (url, title, image, description) VALUES(:url, :title, :image, :descr)”); $query->bindValue(“:url”, “http://www.imgur.com”, PDO::PARAM_STR); $query->bindValue(“:title”, $title, PDO::PARAM_STR); $query->bindValue(“:image”, $image, … Read more

[Solved] Send email from php

[ad_1] change $header to $headers, you’ve got $headers = “From: $from\r\n”; and using $header mail($to, $subject, $message,$headers); so whole code would look like <?php //change this to your email. $to = “[email protected]”; $from = “[email protected]”; $subject = “Hello! This is HTML email”; $message = “hello”; $headers = “From: $from\r\n”; $headers .= “Content-type: text/html\r\n”; mail($to, $subject, … Read more

[Solved] PHP Insert Table Data Code not Inserting Data into MSSQL Table [closed]

[ad_1] MSSQL doesn’t have a direct md5 function (you can convert it as demonstrated here). You need to use it through PHP like so: $sqla = “INSERT INTO users (username, password) VALUES (‘rob_dewar01’, ‘” . md5(‘KingDozer’) . “‘)”; Also, md5 is not secure. Look into using prepared statements. See the Secure hash and salt for … Read more

[Solved] PHP/SQL Delete button for each row [closed]

[ad_1] You should use mysqli or pdo You have missed 3 points: fix your query: 1) make sure you have selected all required fields. $filme_cart = mysql_query(“SELECT * FROM cart_test GROUP BY name”); 2) Try using: mysql_fetch_assoc <?php while($film_cart=mysql_fetch_assoc($filme_cart)) { echo “<tr>”; echo “<td align=’left’>”; echo $film_cart[‘name’]; echo “</td>”; echo “<td class=”cart-product-setting”>”; echo $film_cart[‘price’]; echo … Read more

[Solved] Need help comparing times using datetime [closed]

[ad_1] This doesn’t work because you compare a DateTime object with a string. You need to use two DateTime objects: $store_closed = DateTime::createFromFormat (‘H:i:s’, ‘1:00:00’); echo ($store_closed > $set_time) ? ‘yes’ : ‘no’; 1 [ad_2] solved Need help comparing times using datetime [closed]

[Solved] Selection radio button

[ad_1] <script> function myFunction() { var x = document.getElementsByName(‘os’); var rate_value; for(var i = 0; i < x.length; i++){ if(x[i].checked){ rate_value = x[i].value; break; } } document.getElementById(“demo”).innerHTML = rate_value; } </script> 2 [ad_2] solved Selection radio button

[Solved] How can I update the marker cluster from the map based on the list of locations?

[ad_1] In the API documentation for the Marker Clusterer add-on, the methods list contains boolean removeMarker(marker:google.maps.Marker)Removes a marker from the cluster. In order to use that method within the click handler (i.e. clickHandlerDelegate()), the declaration (i.e. with keyword var) will need to be moved out of the initialize function: var map; //set scope here so … Read more

[Solved] SQL Multiple request

[ad_1] Try this instead: $result = doQuery(“SELECT DISTINCT c.PkID, c.CategoryName FROM ” . HC_TblPrefix . “categories c WHERE c.IsActive = 1 AND c.PkID IN (‘”. implode(“‘, ‘”, explode(“,”, $catIDs)) .”‘) ORDER BY c.CategoryName”); The reason your loop is only returning the last result is because you overwrite $resultCat every time, so when your loop is … Read more

[Solved] php – Set variable to result of if statement [closed]

[ad_1] The way you want to do this… To answer the original question re: your formatting, you can use an if statement to define a variable, but it’s not particularly readable: $myVariable = (strlen($myString) > 0) ? ‘<p>’.$myString.'</p>’ : ”; echo $myVariable; Live demo. Recommended way to do this… However, in your case this is … Read more