{"id":14792,"date":"2022-10-09T04:33:47","date_gmt":"2022-10-08T23:03:47","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-php-sql-query-isnt-returning-anything\/"},"modified":"2022-10-09T04:33:47","modified_gmt":"2022-10-08T23:03:47","slug":"solved-php-sql-query-isnt-returning-anything","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-php-sql-query-isnt-returning-anything\/","title":{"rendered":"[Solved] PHP sql query isn&#8217;t returning anything"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-23254912\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"23254912\" data-parentid=\"23254578\" data-score=\"2\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>From the manual:<\/p>\n<blockquote>\n<p><em>Identifiers may begin with a digit but unless quoted may not consist solely of digits.<\/em><\/p>\n<\/blockquote>\n<ul>\n<li><strong><a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.1\/en\/identifiers.html\">http:\/\/dev.mysql.com\/doc\/refman\/5.1\/en\/identifiers.html<\/a><\/strong><\/li>\n<\/ul>\n<p>Which is exactly what you&#8217;re doing, and should not be doing.<\/p>\n<p><strong><em>Solution:<\/em><\/strong> <\/p>\n<ol>\n<li>\n<p>Choose a different name for your table, one consisting of letters preferably.<\/p>\n<\/li>\n<li>\n<p>Use backticks around the table name.<\/p>\n<\/li>\n<\/ol>\n<p><em>Plus,<\/em> if you wish to view data, you need to use a loop.<\/p>\n<p><strong>I.e.:<\/strong><\/p>\n<pre><code>$query=\"SELECT * FROM `140423` WHERE GAME='Clash of Clans'\";\n\n    while ($row = mysql_fetch_assoc($query)) \n            {\n                $var = $row[\"column\"]; \/\/ the column of your choice\n            }\n\n        echo $var;\n<\/code><\/pre>\n<hr>\n<p>Rewrite:<\/p>\n<pre><code>$dbc = mysql_connect ('localhost','root','abcde');\n\nif (!$dbc) {\ndie('Not Connected:' . mysql_error ());\n}\n\n$db_selected = mysql_select_db ('db_test', $dbc);\n\nif (!$db_selected) {\ndie (\"Can't Connect :\" .mysql_error());\n}\n\n$query=\"SELECT * FROM `140423` WHERE GAME='Clash of Clans'\";\n\/\/add \"result\"\n$result=mysql_query($query);\n\n\/\/ as pointed out already\n    if (!$result) {\n    die (\"Can't Connect :\" .mysql_error());\n    }\n\necho $result; \/\/ this is up to you\n\n\/\/ if you want to see data from your table, loop through it.\n\n    while ($row = mysql_fetch_assoc($query)) \n            {\n                $var = $row[\"column\"]; \/\/ the column of your choice\n            }\n\n        echo $var;\n<\/code><\/pre>\n<hr>\n<p><strong>Footnotes:<\/strong><\/p>\n<p><code>mysql_*<\/code> functions deprecation notice:<\/p>\n<p><a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/www.php.net\/manual\/en\/intro.mysql.php\">http:\/\/www.php.net\/manual\/en\/intro.mysql.php<\/a><\/p>\n<p>This extension is deprecated as of PHP 5.5.0, and is not recommended for writing new code as it will be removed in the future. Instead, either the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/www.php.net\/manual\/en\/book.mysqli.php\"><strong>mysqli<\/strong><\/a> or <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/www.php.net\/manual\/en\/ref.pdo-mysql.php\"><strong>PDO_MySQL<\/strong><\/a> extension should be used. See also the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/www.php.net\/manual\/en\/mysqlinfo.api.choosing.php\"><strong>MySQL API Overview<\/strong><\/a> for further help while choosing a MySQL API. <\/p>\n<p>These functions allow you to access MySQL database servers. More information about MySQL can be found at \u00bb <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/www.mysql.com\/\">http:\/\/www.mysql.com\/<\/a>.<\/p>\n<p>Documentation for MySQL can be found at \u00bb <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/dev.mysql.com\/doc\/\">http:\/\/dev.mysql.com\/doc\/<\/a>.<\/p>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\"><\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved PHP sql query isn&#8217;t returning anything <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] From the manual: Identifiers may begin with a digit but unless quoted may not consist solely of digits. http:\/\/dev.mysql.com\/doc\/refman\/5.1\/en\/identifiers.html Which is exactly what you&#8217;re doing, and should not be doing. Solution: Choose a different name for your table, one consisting of letters preferably. Use backticks around the table name. Plus, if you wish to &#8230; <a title=\"[Solved] PHP sql query isn&#8217;t returning anything\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-php-sql-query-isnt-returning-anything\/\" aria-label=\"More on [Solved] PHP sql query isn&#8217;t returning anything\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[339,341,597],"class_list":["post-14792","post","type-post","status-publish","format-standard","hentry","category-solved","tag-php","tag-sql","tag-wordpress"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] PHP sql query isn&#039;t returning anything - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-php-sql-query-isnt-returning-anything\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] PHP sql query isn&#039;t returning anything - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] From the manual: Identifiers may begin with a digit but unless quoted may not consist solely of digits. http:\/\/dev.mysql.com\/doc\/refman\/5.1\/en\/identifiers.html Which is exactly what you&#8217;re doing, and should not be doing. Solution: Choose a different name for your table, one consisting of letters preferably. Use backticks around the table name. Plus, if you wish to ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-php-sql-query-isnt-returning-anything\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-10-08T23:03:47+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\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\":\"https:\/\/jassweb.com\/solved\/solved-php-sql-query-isnt-returning-anything\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-php-sql-query-isnt-returning-anything\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] PHP sql query isn&#8217;t returning anything\",\"datePublished\":\"2022-10-08T23:03:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-php-sql-query-isnt-returning-anything\/\"},\"wordCount\":186,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"php\",\"sql\",\"wordpress\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-php-sql-query-isnt-returning-anything\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-php-sql-query-isnt-returning-anything\/\",\"name\":\"[Solved] PHP sql query isn't returning anything - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2022-10-08T23:03:47+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-php-sql-query-isnt-returning-anything\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-php-sql-query-isnt-returning-anything\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-php-sql-query-isnt-returning-anything\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] PHP sql query isn&#8217;t returning anything\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] PHP sql query isn't returning anything - JassWeb","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":"https:\/\/jassweb.com\/solved\/solved-php-sql-query-isnt-returning-anything\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] PHP sql query isn't returning anything - JassWeb","og_description":"[ad_1] From the manual: Identifiers may begin with a digit but unless quoted may not consist solely of digits. http:\/\/dev.mysql.com\/doc\/refman\/5.1\/en\/identifiers.html Which is exactly what you&#8217;re doing, and should not be doing. Solution: Choose a different name for your table, one consisting of letters preferably. Use backticks around the table name. Plus, if you wish to ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-php-sql-query-isnt-returning-anything\/","og_site_name":"JassWeb","article_published_time":"2022-10-08T23:03:47+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-php-sql-query-isnt-returning-anything\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-php-sql-query-isnt-returning-anything\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] PHP sql query isn&#8217;t returning anything","datePublished":"2022-10-08T23:03:47+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-php-sql-query-isnt-returning-anything\/"},"wordCount":186,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["php","sql","wordpress"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-php-sql-query-isnt-returning-anything\/","url":"https:\/\/jassweb.com\/solved\/solved-php-sql-query-isnt-returning-anything\/","name":"[Solved] PHP sql query isn't returning anything - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-10-08T23:03:47+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-php-sql-query-isnt-returning-anything\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-php-sql-query-isnt-returning-anything\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-php-sql-query-isnt-returning-anything\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] PHP sql query isn&#8217;t returning anything"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/14792","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=14792"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/14792\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=14792"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=14792"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=14792"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}