{"id":262,"date":"2021-04-08T20:18:20","date_gmt":"2021-04-08T20:18:20","guid":{"rendered":"http:\/\/doableyo.com\/yes\/?p=262"},"modified":"2021-04-08T20:24:00","modified_gmt":"2021-04-08T20:24:00","slug":"php-sql-returns-space-in-email-address-while-query-with-json-post-data-using-post-method","status":"publish","type":"post","link":"http:\/\/doableyo.com\/yes\/php-sql-returns-space-in-email-address-while-query-with-json-post-data-using-post-method\/","title":{"rendered":"PHP sql returns space in email address while query with json post data using post method"},"content":{"rendered":"\n<p>I have faced a scenario where I was getting space error in the email address before @ symbol in email address, as I were making simple post request to verify the login. <br>Json post object sample:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n\t\"email\": \"test@example.com\",\n  \t\"password\" : \"test123\"\n}<\/code><\/pre>\n\n\n\n<p>Was returning error in response of like test @example.com so the email address was not getting verified in the database.<\/p>\n\n\n\n<p>Upon google came to following stack overflow <a rel=\"noreferrer noopener\" href=\"https:\/\/stackoverflow.com\/questions\/58313601\/json-response-giving-an-error-of-invalid-email-address-using-php-get-method-in-s\/67011163#67011163\" target=\"_blank\">result <\/a>for solution but not satisfy with the approach of replacing single quote again and forcing self to post the email address with single quote in post request, which is obviously not a good solution. (later I have commented on the result page with my solution \ud83d\ude09 )<br>Simply I did this at query level and it resolve the space issue in the email address while query in database. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$query = \"SELECT * FROM \n            \" . $this->table_name . \" \n            WHERE email =  '\".$this->email.\"'  LIMIT 0,1\";\n<\/code><\/pre>\n\n\n\n<p>Finally, wrapped the email address variable with the single quotes, and resolved the issue of space before @ symbol.<\/p>\n\n\n\n<p>Hope this solution and result page will save your day!<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have faced a scenario where I was getting space error in the email address before @ symbol in email address, as I were making simple post request to verify the login. Json post object sample: Was returning error in response of like test @example.com so the email address was not getting verified in the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-262","post","type-post","status-publish","format-standard","hentry","category-uncategorized","entry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PHP sql returns space in email address while query with json post data using post method - DoableYo!<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/doableyo.com\/yes\/php-sql-returns-space-in-email-address-while-query-with-json-post-data-using-post-method\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP sql returns space in email address while query with json post data using post method - DoableYo!\" \/>\n<meta property=\"og:description\" content=\"I have faced a scenario where I was getting space error in the email address before @ symbol in email address, as I were making simple post request to verify the login. Json post object sample: Was returning error in response of like test @example.com so the email address was not getting verified in the [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"http:\/\/doableyo.com\/yes\/php-sql-returns-space-in-email-address-while-query-with-json-post-data-using-post-method\/\" \/>\n<meta property=\"og:site_name\" content=\"DoableYo!\" \/>\n<meta property=\"article:published_time\" content=\"2021-04-08T20:18:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-04-08T20:24:00+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/doableyo.com\/yes\/php-sql-returns-space-in-email-address-while-query-with-json-post-data-using-post-method\/#article\",\"isPartOf\":{\"@id\":\"http:\/\/doableyo.com\/yes\/php-sql-returns-space-in-email-address-while-query-with-json-post-data-using-post-method\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/doableyo.com\/yes\/#\/schema\/person\/0b9be73850e0b7b2bda8b903e2ea07c3\"},\"headline\":\"PHP sql returns space in email address while query with json post data using post method\",\"datePublished\":\"2021-04-08T20:18:20+00:00\",\"dateModified\":\"2021-04-08T20:24:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/doableyo.com\/yes\/php-sql-returns-space-in-email-address-while-query-with-json-post-data-using-post-method\/\"},\"wordCount\":174,\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/doableyo.com\/yes\/php-sql-returns-space-in-email-address-while-query-with-json-post-data-using-post-method\/\",\"url\":\"http:\/\/doableyo.com\/yes\/php-sql-returns-space-in-email-address-while-query-with-json-post-data-using-post-method\/\",\"name\":\"PHP sql returns space in email address while query with json post data using post method - DoableYo!\",\"isPartOf\":{\"@id\":\"https:\/\/doableyo.com\/yes\/#website\"},\"datePublished\":\"2021-04-08T20:18:20+00:00\",\"dateModified\":\"2021-04-08T20:24:00+00:00\",\"author\":{\"@id\":\"https:\/\/doableyo.com\/yes\/#\/schema\/person\/0b9be73850e0b7b2bda8b903e2ea07c3\"},\"breadcrumb\":{\"@id\":\"http:\/\/doableyo.com\/yes\/php-sql-returns-space-in-email-address-while-query-with-json-post-data-using-post-method\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/doableyo.com\/yes\/php-sql-returns-space-in-email-address-while-query-with-json-post-data-using-post-method\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/doableyo.com\/yes\/php-sql-returns-space-in-email-address-while-query-with-json-post-data-using-post-method\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/doableyo.com\/yes\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PHP sql returns space in email address while query with json post data using post method\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/doableyo.com\/yes\/#website\",\"url\":\"https:\/\/doableyo.com\/yes\/\",\"name\":\"DoableYo!\",\"description\":\"Yo is the boost behind it!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/doableyo.com\/yes\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/doableyo.com\/yes\/#\/schema\/person\/0b9be73850e0b7b2bda8b903e2ea07c3\",\"name\":\"admin\",\"url\":\"http:\/\/doableyo.com\/yes\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PHP sql returns space in email address while query with json post data using post method - DoableYo!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/doableyo.com\/yes\/php-sql-returns-space-in-email-address-while-query-with-json-post-data-using-post-method\/","og_locale":"en_US","og_type":"article","og_title":"PHP sql returns space in email address while query with json post data using post method - DoableYo!","og_description":"I have faced a scenario where I was getting space error in the email address before @ symbol in email address, as I were making simple post request to verify the login. Json post object sample: Was returning error in response of like test @example.com so the email address was not getting verified in the [&hellip;]","og_url":"http:\/\/doableyo.com\/yes\/php-sql-returns-space-in-email-address-while-query-with-json-post-data-using-post-method\/","og_site_name":"DoableYo!","article_published_time":"2021-04-08T20:18:20+00:00","article_modified_time":"2021-04-08T20:24:00+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/doableyo.com\/yes\/php-sql-returns-space-in-email-address-while-query-with-json-post-data-using-post-method\/#article","isPartOf":{"@id":"http:\/\/doableyo.com\/yes\/php-sql-returns-space-in-email-address-while-query-with-json-post-data-using-post-method\/"},"author":{"name":"admin","@id":"https:\/\/doableyo.com\/yes\/#\/schema\/person\/0b9be73850e0b7b2bda8b903e2ea07c3"},"headline":"PHP sql returns space in email address while query with json post data using post method","datePublished":"2021-04-08T20:18:20+00:00","dateModified":"2021-04-08T20:24:00+00:00","mainEntityOfPage":{"@id":"http:\/\/doableyo.com\/yes\/php-sql-returns-space-in-email-address-while-query-with-json-post-data-using-post-method\/"},"wordCount":174,"inLanguage":"en-US"},{"@type":"WebPage","@id":"http:\/\/doableyo.com\/yes\/php-sql-returns-space-in-email-address-while-query-with-json-post-data-using-post-method\/","url":"http:\/\/doableyo.com\/yes\/php-sql-returns-space-in-email-address-while-query-with-json-post-data-using-post-method\/","name":"PHP sql returns space in email address while query with json post data using post method - DoableYo!","isPartOf":{"@id":"https:\/\/doableyo.com\/yes\/#website"},"datePublished":"2021-04-08T20:18:20+00:00","dateModified":"2021-04-08T20:24:00+00:00","author":{"@id":"https:\/\/doableyo.com\/yes\/#\/schema\/person\/0b9be73850e0b7b2bda8b903e2ea07c3"},"breadcrumb":{"@id":"http:\/\/doableyo.com\/yes\/php-sql-returns-space-in-email-address-while-query-with-json-post-data-using-post-method\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/doableyo.com\/yes\/php-sql-returns-space-in-email-address-while-query-with-json-post-data-using-post-method\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/doableyo.com\/yes\/php-sql-returns-space-in-email-address-while-query-with-json-post-data-using-post-method\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/doableyo.com\/yes\/"},{"@type":"ListItem","position":2,"name":"PHP sql returns space in email address while query with json post data using post method"}]},{"@type":"WebSite","@id":"https:\/\/doableyo.com\/yes\/#website","url":"https:\/\/doableyo.com\/yes\/","name":"DoableYo!","description":"Yo is the boost behind it!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/doableyo.com\/yes\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/doableyo.com\/yes\/#\/schema\/person\/0b9be73850e0b7b2bda8b903e2ea07c3","name":"admin","url":"http:\/\/doableyo.com\/yes\/author\/admin\/"}]}},"_links":{"self":[{"href":"http:\/\/doableyo.com\/yes\/wp-json\/wp\/v2\/posts\/262","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/doableyo.com\/yes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/doableyo.com\/yes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/doableyo.com\/yes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/doableyo.com\/yes\/wp-json\/wp\/v2\/comments?post=262"}],"version-history":[{"count":3,"href":"http:\/\/doableyo.com\/yes\/wp-json\/wp\/v2\/posts\/262\/revisions"}],"predecessor-version":[{"id":267,"href":"http:\/\/doableyo.com\/yes\/wp-json\/wp\/v2\/posts\/262\/revisions\/267"}],"wp:attachment":[{"href":"http:\/\/doableyo.com\/yes\/wp-json\/wp\/v2\/media?parent=262"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/doableyo.com\/yes\/wp-json\/wp\/v2\/categories?post=262"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/doableyo.com\/yes\/wp-json\/wp\/v2\/tags?post=262"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}