{"id":10186,"date":"2021-07-03T07:30:05","date_gmt":"2021-07-03T07:30:05","guid":{"rendered":"https:\/\/papersspot.com\/blog\/2021\/07\/03\/define-constant-inside-mysql-connection-string-probelm\/"},"modified":"2021-07-03T07:30:05","modified_gmt":"2021-07-03T07:30:05","slug":"define-constant-inside-mysql-connection-string-probelm","status":"publish","type":"post","link":"https:\/\/papersspot.com\/blog\/2021\/07\/03\/define-constant-inside-mysql-connection-string-probelm\/","title":{"rendered":"Define() Constant inside mysql connection string probelm"},"content":{"rendered":"<p>Here is what i have: <br \/>file one Called config.inc.php: <br \/>[PHP] <br \/>session_register(&#8220;client_id&#8221;); <br \/>$_SESSION[&#8216;client_id&#8217;] = $_SESSION[&#8216;SESS_ACCT_ID&#8217;];\/\/\u00a0 <br \/>$club_id=$_SESSION[&#8216;client_id&#8217;]; <br \/>ob_start(); <br \/>include(&#8216;..\/..\/..\/page_title.php&#8217;); <br \/>ob_end_clean(); <br \/>include(&#8216;..\/..\/..\/datalogin.php&#8217;); <br \/>if (!defined(&#8216;DEFAULT_HOST&#8217;)) define(&#8216;DEFAULT_HOST&#8217;,&#8217;localhost&#8217;); <br \/>if (!defined(&#8216;DEFAULT_USER&#8217;)) define(&#8216;DEFAULT_USER&#8217;,$account_user); <br \/>if (!defined(&#8216;DEFAULT_PASS&#8217;)) define(&#8216;DEFAULT_PASS&#8217;,$account_pass); <br \/>if (!defined(&#8216;DEFAULT_DB&#8217;)) define(&#8216;DEFAULT_DB&#8217;,$account_db);\u00a0 <br \/>[\/PHP] <br \/>the variables inside the define() are from the included datalogin.php. <br \/>Now, from my second file: <br \/>[PHP] <br \/>include(&#8216;config.inc.php&#8217;); <br \/>$link = @mysql_connect(DEFAULT_HOST, DEFAULT_USER, DEFAULT_PASS); <br \/>\/\/var_dump($link); <br \/>if (!$link) { <br \/> \u00a0 \u00a0die(&#8216;Could not connect: &#8216; . mysql_error()); <br \/>} <\/p>\n<p># mysql_query(&#8220;SET SESSION time_zone = &#8216;-0:00&#8217;;&#8221;); <br \/>#mysql_query(&#8220;SET NAMES &#8216;utf8&#8242;&#8221;, $link); <\/p>\n<p>$db_selected = mysql_select_db(DEFAULT_DB, $link); <br \/>if (!$db_selected) { <br \/> \u00a0 \u00a0die (&#8220;Cannot use database: &#8220;.DEFAULT_DB.mysql_error()); <br \/>} <br \/>[\/PHP] <br \/>I&#8217;m unable to pass the variable to both: <br \/>[PHP]$link = @mysql_connect(DEFAULT_HOST, DEFAULT_USER, DEFAULT_PASS);[\/PHP] <br \/>and <br \/>[PHP] <br \/>$db_selected = mysql_select_db(DEFAULT_DB, $link); <br \/>[\/PHP] <br \/>However, I can echo (or print) to screen of: <br \/>DEFAULT_DB <br \/>DEFAULT_HOST <br \/>DEFAULT_USER <br \/>DEFAULT_PASS <br \/>Any ideas as to what is happening with the lost of the values in the db connection string <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is what i have: file one Called config.inc.php: [PHP] session_register(&#8220;client_id&#8221;); $_SESSION[&#8216;client_id&#8217;] = $_SESSION[&#8216;SESS_ACCT_ID&#8217;];\/\/\u00a0 $club_id=$_SESSION[&#8216;client_id&#8217;]; ob_start(); include(&#8216;..\/..\/..\/page_title.php&#8217;); ob_end_clean(); include(&#8216;..\/..\/..\/datalogin.php&#8217;); if (!defined(&#8216;DEFAULT_HOST&#8217;)) define(&#8216;DEFAULT_HOST&#8217;,&#8217;localhost&#8217;); if (!defined(&#8216;DEFAULT_USER&#8217;)) define(&#8216;DEFAULT_USER&#8217;,$account_user); if (!defined(&#8216;DEFAULT_PASS&#8217;)) define(&#8216;DEFAULT_PASS&#8217;,$account_pass); if (!defined(&#8216;DEFAULT_DB&#8217;)) define(&#8216;DEFAULT_DB&#8217;,$account_db);\u00a0 [\/PHP] the variables inside the define() are from the included datalogin.php. Now, from my second file: [PHP] include(&#8216;config.inc.php&#8217;); $link = @mysql_connect(DEFAULT_HOST, DEFAULT_USER, DEFAULT_PASS); \/\/var_dump($link); [&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":[20],"class_list":["post-10186","post","type-post","status-publish","format-standard","hentry","category-research-paper-writing","tag-programming"],"_links":{"self":[{"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/posts\/10186","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/comments?post=10186"}],"version-history":[{"count":0,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/posts\/10186\/revisions"}],"wp:attachment":[{"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/media?parent=10186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/categories?post=10186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/tags?post=10186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}