PHP - Check Domain Name Is Valid Or Not
HI,
I am triying to check a domain is valid or not using PHP. If the domian is not a valid one the name shoud be empty string.
So I tried using preg_match() and preg_replace(). But I couldn't get it to work.
This is my code sofar -
if (preg_match ('/^((?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{2,6}$/', $domain)) { $mydomain = $domain; } else { $mydomain = preg_replace("/^((?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{2,6}$/", "", $domain); }When I am tring using valid and invalid domain name its always going to else part. Eg: example.com example.t.t.c Hope somebody may help me out. Thank you. Similar TutorialsI have this code which performs a mysql query. However is there a way I can check to see if the set it returns is empty. If it is empty I will then change the sql statement. Thanks $announcement_sql = "select * where annnouncement_for like \"%" . $_POST['for_search'] . "%\" and announcement_verification=\"1\" order by announcement_number desc limit 0, 15"; Hi, I am trying to see if the domain name in the string is in an array. eg; Code: [Select] mystring='http://google.com/somethingelse'; myarray[]='google.com'; myarray[]='anotherdomain.com'; in this case return TRUE Code: [Select] mystring='http://phpfreaks.com/adir'; myarray[]='google.com'; myarray[]='anotherdomain.com'; in this case return FALSE How would I do this? Thanks, -mme Code what i made so far.
$inputText = 'This is testing http://www.youtube.com'; $allowedDomains = 'www.google.com youtube.com/ http://www.test.org'; $array = preg_split('/[\s]+/', $allowedDomains); $regex = '';//Need this line if(preg_match($regex, $inputText)){ print 'Domain match!'; }else{ print 'Domain not match!'; } Edited by jacob21, 16 October 2014 - 08:31 AM. I am working on a web form in PHP which accepts a Paypal Email address from the user. I need to authenticate (validate or check) if the Paypal email address entered is a valid Paypal email account. Please reply. All comments and feedback are welcomed. Thank you! I have two domains both running SSL. Let's call them old-domain and new-domain. old-domain is permanently redirecting traffic to new-domain. There are still a lot of links out there to old-domain with https://. If I were to remove SSL from old-domain but keep SSL on new-domain, I am betting that users will be getting some sort of certificate error. Right? Any way around that if I want to remove SSL from old-domain?
This topic has been moved to the corner of 3rd Avenue and mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=359430.0 Hello! First... I'm sorry about my english skills.. Seems that with my own language I don't get a correct or good answer So.. I have a site where visitors can put there favorite links to other sites and show them to others. My problem is multiple urls to same locations in sites-table. example: http://google.com http://google.com/ http://www.google.com http://www.google.com/ http://www.google.com/index.php (?) they all lead to same... is there any light and powerfull way to check these? I'm trying to use query with "like" but it only works if there is exactly same url. I use fopen to check that url really exicst.. table: Sites (basic information for link) -id -url -title +some meta tags if found -timestamp I'm not asking to do me this code. But if someone can tell me just what functions and others I'm looking for and what I need for this... My coal is to keep sites-table as clean as it can be. If visitor adds a url that is already in sites-table only thing that happens is updating timestamp. Thank you all for helping me! -Roosterr $ARR[$i] == $NEEDLE ? $Count++ : $Count I am using it in: private function _countIf($ARR, $NEEDLE){ $Count = 0; for($i = 0; $i < count($ARR); i++){ $ARR[$i] == $NEEDLE ? $Count++ : $Count } return $Count; }Edited March 25, 2019 by Karaethon With the following code i can create an xml file. Code: [Select] <?php $myXML = new SimpleXMLElement("<myroot></myroot>"); $title= $myXML->addChild('title'); $title->addAttribute('number','12'); $titleName= $title->addChild('titleName', 'title1'); $titleLink= $title->addChild('titleLink', 'link1'); Header('Content-type: text/xml'); echo $myXML->asXML(); ?> But when i check the validity of xml file http://www.validome.org/xml/validate/ This error occurs: Can not find declaration of element 'myroot'. I suppose that the problem is missing of !DOCTYPE and !ELEMENT lines. How can i create valid XML documents with PHP automatically?? Is it possible to make it without writing doctype and element types for the whole element types of xml by hand $title, $titleName and $titleLink Thank you I'm trying to list all the tables in my database. I got this code pretty much "word" for word from the example at php.net, but I get: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in E:\wamp\www\test\test-in.php on line 67 <?php $db= $_POST['db']; $sql= "SHOW TABLES FROM $db"; $result=mysql_query($sql); while ($tblarray = mysql_fetch_row($result)){ ?><a href="?tablename=<?php echo $tblarray[0];?>"><?php echo $tblarray[0];?></a><?php } ?> Okay, I have a table with two columns..'annoyed' and 'ignored'. I poulated 'annoyed' with Bob and 'ignored' with Sally. I ran the following test due to problems I was having in my main script and I get the old MySQL "Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home2/testing_ig.php on line 16 Here is the code: <?php $DBhost = "localhost"; $DBuser = "xxxxx"; $DBpass = "xxxxx"; $DBName = "xxxxx"; $table = "ignore"; mysql_connect($DBhost,$DBuser,$DBpass) or die(); @mysql_select_db("$DBName") or die(); $ignorequery = "SELECT * FROM $table WHERE annoyed='Bob' AND ignored='Sally'"; $checkignore = mysql_query($ignorequery); $ifignored = mysql_num_rows($checkignore); //<--- This is line 16 if ($ifignored >= 1) { echo "exists"; } else { echo "doesn't exist"; } ?> I must be really tired because I'm not seeing the problem...? What is wrong? Warning: mysql_select_db(): supplied resource is not a valid MySQL-Link resource in /home/rweekly/public_html/2012/view_arguments.php on line 41 Warning: mysql_query(): supplied resource is not a valid MySQL-Link resource in /home/rweekly/public_html/2012/view_arguments.php on line 43 Code: [Select] mysql_select_db($database_news, $news); $query_news = "SELECT * FROM news WHERE id = '$id'"; $news = mysql_query($query_news, $news) or die(mysql_error()); $row_news = mysql_fetch_assoc($news); $totalRows_news = mysql_num_rows($news); mysql_select_db($database_news, $news); $query_arguments = "SELECT * FROM argue WHERE pid = '$id'"; $arguments = mysql_query($query_arguments, $news) or die(mysql_error()); $row_arguments = mysql_fetch_assoc($arguments); $totalRows_arguments = mysql_num_rows($arguments); I always use my queries like below mysql_query("SELECT id FROM someTable", $cn); but some times i see in my error_log says: mysql_fetch_array(): supplied argument is not a valid MySQL result resource. Why is this happening? I mean, there is no problem with my sites and all they are working as they should be but why php generates this error? Hi, I am trying to create a mobile version of my already uploaded file using below code but getting this error imagecreatefrompng(): is not a valid PNG file Here is the code: if (move_uploaded_file($_FILES['photo']['tmp_name'], $uploadedFile)) { $resource = imagecreatefrompng($uploadedFile); $small_file = imagescale($resource , 500, 400); $small_file = imagepng($small_file); $newSmallFile = "mobile-" . $gallery_uuid . '.png'; $uploadedSmallFile = $uploaddir . $newSmallFile; echo $uploadedSmallFile; if (move_uploaded_file($small_file, $uploadedSmallFile)) { } else { echo json_encode("error"); } } else { echo json_encode("error"); }
Kindly help..
Thanks, Jassim Edited July 29 by requinix removing link Hello all, I'm currently doing this Facebook connect module for my website. With the FBconnect, it creates a user profile on my mysql, which stores only the Facebook userid, the full name, and the thumbnail url of this user. Currently the code works well except for this 'image url checking'. this is my fb profile image url: http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs349.snc4/41540_772137439_5612219_q.jpg when I've added a 'XXX' at the back ( http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs349.snc4/41540_772137439_5612219_qXXX.jpg ). It returns a blank instead. On Facebook, some accounts are not genuine and they might the deleted sooner or later. So I'm trying to figure out a php script or functions which detect if the image is not the 'XXX' version. I've tried using getimagesize() or file_get_contents() but still won't work. any ideas? I need to close a window if referer not valid, but it cannot be in HTML, needs to be php. This is what I have so far: Code: [Select] if (ereg("http://www.mysite.com/test.php", $_SERVER['HTTP_REFERER']) != true){ header('Location: ?????????'); exit; } I get a header already sent message if I use a URL. I need it to close the window after 3 seconds. Any ideas? I have searched for this topic here but have not found reference to it. I am receiving the following: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/a4542527/public_html/index.php on line 8 The scripting for this is basic at this point (I am building something in steps and this is just a test section: The script will call data from the table and display said data.) The following is the code (two, separate files located on my server)- I am hoping that someone may see something that I am missing. connection.php <?php $dbhost = 'mysql7.000webhost.com'; $dbuser = 'a4542527_root'; $dbpass = '**********'; $db = 'a4542527_test1'; $conn = mysql_connect($dbhost,$dbuser,$dbpass); mysql_select_db($db); ?> index.php <?php include 'connection.php'; $query = "SELECT * FROM people"; $result = "mysql_query($query)"; while ($person = mysql_fetch_array($result)){ echo $person ['name']; echo $person ['descrip']; } ?> Thank-you for any help, suggestions or a point in the right direction. ~Matty Hi there, I was thinking of using this following check system to see if a user has entered a good valid value for a categories selection, but it is just is_numeric, here's my line of single code for this: Code: [Select] if(!array_key_exists('category', $_GET) || trim(is_numeric($_GET['category'])) == '') Is there anything better that I can be using than is_numeric()? I mean this would allow 2.22 which for the categories selection, would not be valid, I will only be allowing integer values, I mean it would potentially come up with no category selected but that wouldn't be very good would it? It could be applied to a blog I am doing aswell, any guidance on such an improvement on this function would very much be appreciated, Jeremy. Hi everyone!! I finish to do my second populating drop down list. it's not realy the display I was looking but for now it will be good. but when I click on my serach button I receive this erro. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\scale24-25\search-keyword.php on line 112 this is what line 112 is in the search file. //-create while loop and loop through result set while($row=mysql_fetch_array($result)){ <-------------- line 112 here's the code of my form... <?php include_once("connection.php"); ////////////////////////////// ?> <!doctype html public "-//w3c//dtd html 3.2//en"> <html> <head> <title>1/24 - 1/25 scale model database</title> <SCRIPT language=JavaScript> function reload(form) { var val=form.cat.options[form.cat.options.selectedIndex].value; self.location='search-db-foreach.php?cat=' + val ; } </script> </head> <body > <img src="http://www.scale24-25.com/images/banners/banner.jpg" alt="banner" width="997" height="213" border="0" usemap="#Map" /> <map name="Map" id="Map"> <area shape="poly" coords="0,100,85,102,92,55,108,50,326,51,323,7,3,3" href="http://www.hobby-shop.qc.ca" alt="hobby-shop" /> <area shape="poly" coords="672,57,891,53,887,4,995,4,985,108,673,102" href="http://www.hobby-shop.qc.ca" alt="hobby-shop" /> <area shape="poly" coords="326,13,330,53,98,54,90,92,670,99,668,54,889,51,886,5" href="http://www.scale-auto-style.com" alt="" /> </map> <?php if (isset($_POST['todo']) && $_POST['todo'] == "search") { $todo=$_POST['todo']; $manufacturer_reel=$_POST['manufacturer_reel']; $query="select * from kit where "; ////////// Including manufacturer_reel field search //// if(strlen($manufacturer_reel) > 0 ){ $query.= " manufacturer_reel='$manufacturer_reel' and "; } //// End of class field search /////////// $query=substr($query,0,(strLen($query)-4)); echo $query; echo "<br><br>"; $nt=mysql_query($query); echo mysql_error(); // End if form submitted }else{ echo "<form method=post action='search-keyword.php?go'><input type=hidden name=todo value=search>"; ?> <table width="960" border="0"> <tr> <td colspan="3"><table width="100%" border="0"> <tr> </tr> <tr> <td><div align="right"></div></td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td><div align="right">Echelle du modele</div></td> <td align="center"> <?php // strat of drop down /// $q=mysql_query("SELECT DISTINCT scale FROM kit ORDER BY scale"); echo '<select name="scale"><option value="scale">Please Choose an Option</option>'; while($row = mysql_fetch_array($q)) { $thing = $row['scale']; echo '<option>'.$thing.'</option>'; } echo "</select>"; echo " <br> \n"; echo " <br> \n"; ?></td> <td><div align="left">Scale of model</div></td> </tr> <tr> <td> </td> <td> </td> <td><div align="right"></div></td> </tr> <tr> <td><div align="right">Nom du manufacturier automobile</div></td> <td align="center"><?php // strat of drop down /// /* If register_global is off in your server then after reloading of the page to get the value of cat from query string we have to take special care. @$cat=$_GET['cat']; // Use this line or below line if register_global is off if(strlen($cat) > 0 and !is_numeric($cat)){ // to check if $cat is numeric data or not. echo "Data Error"; exit; } */ @$cat=$HTTP_GET_VARS['cat']; // Use this line or above line if register_global is off ///////// Getting the data from Mysql table for first list box////////// $quer2=mysql_query("SELECT DISTINCT manufacturer_reel,manufacturer_reel_id FROM kit order by manufacturer_reel"); ///////////// End of query for first list box//////////// /////// for second drop down list we will check if manufacturer_reel is selected else we will display all the car_model///// if(isset($cat) and strlen($cat) > 0){ $quer=mysql_query("SELECT DISTINCT car_model FROM kit where manufacturer_reel_id=$cat order by car_model"); }else{$quer=mysql_query("SELECT DISTINCT car_model FROM kit order by car_model"); } ////////// end of query for second car_model drop down list box /////////////////////////// ////////// Starting of first drop downlist ///////// echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>Select one</option>"; while($noticia2 = mysql_fetch_array($quer2)) { if($noticia2['manufacturer_reel_id']==@$cat){echo "<option selected value='$noticia2[manufacturer_reel_id]'>$noticia2[manufacturer_reel]</option>"."<BR>";} else{echo "<option value='$noticia2[manufacturer_reel_id]'>$noticia2[manufacturer_reel]</option>";} } echo "</select>"; ////////////////// This will end the first drop down list /////////// ////////// Starting of second drop downlist ///////// echo "<select name='subcat'><option value=''>Select one</option>"; while($noticia = mysql_fetch_array($quer)) { echo "<option value='$noticia[car_model]'>$noticia[car_model]</option>"; } echo "</select>"; // end of drop down /// echo " <br> \n"; echo " <br> \n"; // end of drop down /// ?></td> <td><div align="left">Name Of vehicule manufacturer</div></td> </tr> <tr> <td> </td> <td> </td> <td><div align="right"></div></td> </tr> <tr> <td><div align="right">Nom du manufacturier de modele reduit</div></td> <td align="center"><?php // start of drop down /// $q=mysql_query("SELECT DISTINCT manufacturer_kit FROM kit ORDER BY manufacturer_kit"); echo '<select name="manufacturer_kit"><option value="kit manufacturer">Please Choose an Option</option>'; while($row = mysql_fetch_array($q)) { $thing = $row['manufacturer_kit']; echo '<option>'.$thing.'</option>'; } echo "</select>"; // end of drop down /// echo " <br> \n"; echo " <br> \n"; ?></td> <td><div align="left">Name Of kit manufacturer</div></td> </tr> <tr> <td><div align="right"></div></td> <td> </td> <td> </td> </tr> <tr> <td><div align="right">Annee de fabrication du Vehicule</div></td> <td align="center"><?php // strat of drop down /// $q=mysql_query("SELECT DISTINCT year_prod_reel FROM kit ORDER BY year_prod_reel"); echo '<select name="year_prod_reel"><option value="vehicules year manufactured">Please Choose an Option</option>'; while($row = mysql_fetch_array($q)) { $thing = $row['year_prod_reel']; echo '<option>'.$thing.'</option>'; } echo "</select>"; // end of drop down /// echo " <br> \n"; echo " <br> \n"; ?></td> <td><div align="left">Year of production of the vehicule</div></td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td align="center"> </td> <td> </td> </tr> <tr> <td><div align="right"><strong></strong></div></td> <td align="center"> <?php echo " <br><input type=submit value=Search name='name' action='search-keyword.php?go' > </form> "; } ?> <td><div align="left"><strong></strong></div></td> </table> </body> </html> and this the search file <?php include_once("connection.php"); ////////////////////////////// ?> <!doctype html public "-//w3c//dtd html 3.2//en"> <html> <head> <title>(Type a title for your page here)</title> </head> <body > <p align="center"><img src="http://www.scale24-25.com/catalog/images/banners/banner.jpg" alt="banner" width="997" height="213" border="0" usemap="#Map" /> <map name="Map" id="Map"> <area shape="poly" coords="0,100,85,102,92,55,108,50,326,51,323,7,3,3" href="http://www.hobby-shop.qc.ca" alt="hobby-shop" /> <area shape="poly" coords="672,57,891,53,887,4,995,4,985,108,673,102" href="http://www.hobby-shop.qc.ca" alt="hobby-shop" /> <area shape="poly" coords="326,13,330,53,98,54,90,92,670,99,668,54,889,51,886,5" href="http://www.scale-auto-style.com" alt="" /> </map></p> <table width="920" border="0"> <tr> <td width="359"><p class="style5">You will find some TBC. TBC is for "To Be Confirmed". If somebody know the missing information ( TBC ) it will be appreciate to send it to me at this mail: <a href="mailto:info@hobby-shop.qc.ca">info@hobby-shop.qc.ca</a> <br /> <br /> thanks in advance for your help</p> </td> <td width="161"><div align="center"><a href="search-db-foreach.php"><img src="catalog/images/design_web/othersearch.jpg" border="0" alt="search" width="150" height="96"></a></div></td> <td width="386"> <div align="right"> <p>This logo <img src= 'http://www.scale24-25.com/images/PDF_logo.gif' width='50' height='50'/> mean that you can download a PDF file. To read it you need minimum Acrobat reader and you can download it <a href="http://get.adobe.com/reader/">here</a></p> <p>Some link will return a TBC. Sorry for any inconveniant. as soon as we will receive or do the PDF it will be updated.</p> </div></td> </tr> </table> <br> <?php if (isset($_POST['todo']) && $_POST['todo'] == "search") { $todo=$_POST['todo']; $name=$_POST['cat']; $name1=$_POST['manufacturer_kit']; $name2=$_POST['year_prod_reel']; $name3=$_POST['scale']; $name11=$_POST['subcat']; //-query the database table for the post field $sql="SELECT kit_id, kit_number, kit_name, description_eng, description_fr, manufacturer_kit, manufacturer_reel, manufacturer_reel_id, scale, engine_detail, year_prod_kit, year_prod_reel, image_id, image_id1, image_id2 FROM kit "; $sqlOperand="WHERE"; if ($name != "cat") { $sql = $sql . $sqlOperand . " cat LIKE '%" . $name ."%' "; $sqlOperand = " AND "; } if ($name1 != "kit manufacturer") { $sql = $sql . $sqlOperand . " manufacturer_kit LIKE '%" . $name1 ."%' "; $sqlOperand = " AND "; } if ($name11 != "subcat") { $sql = $sql . $sqlOperand . " subcat LIKE '%" . $name11 ."%' "; $sqlOperand = " AND "; } if ($name2 != "vehicules year manufactured") { $sql = $sql . $sqlOperand . " year_prod_reel LIKE '%" . $name2 ."%' "; $sqlOperand = " AND "; } if ($name3 != "scale") { $sql = $sql . $sqlOperand . " scale LIKE '%" . $name3 ."%' "; $sqlOperand = " AND "; } if ($sqlOperand == "WHERE") { echo "<p>Please enter a search query</p>"; } else { // echo '<img src="web-design/sorry.jpg" alt="sorry">'; // echo "Sorry nothing match your selection / Desolle rien ne correspond a votre selection"; // echo "run sql: <BR> $sql <BR> and display results"; } //-run the query against the mysql query function $result=mysql_query($sql); //-make the header of the table echo " <table align=center width=\"1340\" border=\"\">\n"; echo " <tr>\n"; echo" <td nowrap align=center width='95'> kit manufacturer \n"; echo" <td nowrap align=center width='55'> scale \n"; echo" <td nowrap align=center width='90'> kit number \n"; echo" <td nowrap align=center width='290'> kit name \n"; echo" <td nowrap align=center width='400'> description \n"; echo" <td nowrap align=center width='125'> vehicule year \n"; echo" <td nowrap align=center width='80'> complete engine detail\n"; echo" <td nowrap align=center width='80'> Select Picture to get bigger\n"; echo" <td nowrap align=center width='75'> instruction sheet\n"; echo" <td nowrap align=center width='75'> box contain\n"; echo " <tr>\n"; //-create while loop and loop through result set while($row=mysql_fetch_array($result)){ $description_eng =$row['description_eng']; $manufacturer_kit=$row['manufacturer_kit']; $scale=$row['scale']; $manufacturer_reel=$row['manufacturer_reel']; $kit_id=$row['kit_id']; $kit_number=$row['kit_number']; $kit_name=$row['kit_name']; $engine_detail=$row['engine_detail']; $year_prod_reel=$row['year_prod_reel']; $image_id=$row['image_id']; $image_id1=$row['image_id1']; $image_id2=$row['image_id2']; //-create table of item during he while loop echo " <table align=center width=\"1340\" border=\"\">\n"; echo" <td nowrap align=center width='95'> $manufacturer_kit \n"; echo" <td nowrap align=center width='55'> $scale \n"; echo" <td nowrap align=center width='90'> $kit_number \n"; echo" <td nowrap align=center width='290'> $kit_name \n"; echo" <td nowrap width='400'> $description_eng \n"; echo" <td nowrap align=center width='125'> $year_prod_reel \n"; echo" <td nowrap align=center width='80'> $engine_detail \n"; echo" <td nowrap width='80'> <a href=".$image_id."> <img src='".$image_id."' width='75' height='50' border='0'/>"; echo" <td nowrap width='75'> <a href= ".$image_id1."> <img src= 'http://www.scale24-25.com/images/PDF_logo.gif' width='50' height='50' border='0'/>"; echo" <td nowrap width='75'> <a href=".$image_id2."> <img src='http://www.scale24-25.com/images/PDF_logo.gif' width='50' height='50' border='0'/>"; echo " </tr>\n"; echo " </table>\n"; echo " </tr>\n"; echo " </table>\n"; } } else{ echo "<p>Please enter a search query</p>"; } ?> </body> </html> so what I do wrong. I knowI forgot something but what???? thanks in advance for your help sebastien Hey there, I am using prototype to send JSON information to a PHP file which will then use the data to update a database, the AJAX presently looks as follows: Code: [Select] function saveprofile() { var email = document.getElementById("email").value; var profileDetails = { "email":email, "titleitalic":titleitalic, "profileDetails":titlefontcolor, "titlefontcolor":titleunderline, "titleoffsettop":titleoffsettop, "titleoffsetleft":titleoffsetleft, "aboutbackgroundcolour":aboutbackgroundcolour, "aboutunderline":aboutunderline, "aboutfontfamily":aboutfontfamily, "aboutbold":aboutbold, "aboutitalic":aboutitalic, "aboutfontcolor":aboutfontcolor, "aboutoffsettop":aboutoffsettop, "aboutoffsetleft":aboutoffsetleft, "statusoffsetleft":statusoffsetleft, "statusinfooffsetright":statusinfooffsetright, "pictureoffsetleft":pictureoffsetleft, "profilebold":profilebold, "profileunderline":profileunderline, "profileitalic":profileitalic, "profilefontcolor":profilefontcolor, "profilefontfamily":profilefontfamily, "profilebackgroundcolour":profilebackgroundcolour } var jsonstring = JSON.stringify(profileDetails); alert(jsonstring); var request = new Ajax.Request ('scripts/updateprofile.php', { method: 'POST', parameters: jsonstring, onComplete: responseReturned } ); } Which outputs the following JSON which has been tested on http://www.jsonlint.com/ as valid: Code: [Select] { "email": "l-wilson-1986@hotmail.co.uk", "titleitalic": "normal", "profileDetails": "#d0deea", "titlefontcolor": "none", "titleoffsettop": 100, "titleoffsetleft": 100, "aboutbackgroundcolour": "transparent", "aboutunderline": "none", "aboutfontfamily": "Arial", "aboutbold": "normal", "aboutitalic": "normal", "aboutfontcolor": "#d0deea", "aboutoffsettop": 325, "aboutoffsetleft": 100, "statusoffsetleft": 450, "statusinfooffsetright": 250, "pictureoffsetleft": 100, "profilebold": "normal", "profileunderline": "none", "profileitalic": "normal", "profilefontcolor": "#fff", "profilefontfamily": "Arial", "profilebackgroundcolour": "#2c3c49" } The PHP file which receives the JSON looks as follows: Code: [Select] <?php $myjson = $_POST['jsonstring']; $jsonchars = json_decode(($myjson), true); $json_errors = array( JSON_ERROR_NONE => 'No error has occurred', JSON_ERROR_DEPTH => 'The maximum stack depth has been exceeded', JSON_ERROR_CTRL_CHAR => 'Control character error, possibly incorrectly encoded', JSON_ERROR_SYNTAX => 'Syntax error', ); echo 'Last error : ', $json_errors[json_last_error()], PHP_EOL, PHP_EOL; // do something with the data ?> The problem is the PHP constantly returns the following error: Last error : Syntax error and any attempts to access the JSON data returns NULL values. I have looked at several online examples and cannot see where I might be going wrong, and although users have had problems with syntax errors it normally relates to incorrect JSON. Any advice on this topic would be greatly appeciated Leanne |