X0ML Posted May 14, 2021 Share Posted May 14, 2021 OK, about ready to go postal, as I've been wasting inordinate amounts of time trying to resolve this issue! If I create basic HTML echo-ed content, PHP works fine. But if I try to reference any database related syntax, the whole PHP web page breaks! VERY FRUSTRATING. This works: <?php // Printing results in HTML echo "<html>\n"; echo "<head>"; echo "</head>"; echo "<body bgcolor=\"#CCCCCC\">"; echo "<CENTER><H1>Current Inventory</H1>"; but this blows up and just gives me a white page with nothing!: <?php // Printing results in HTML echo "<html>\n"; echo "<head>"; echo "</head>"; echo "<body bgcolor=\"#CCCCCC\">"; echo "<CENTER><H1>Current Inventory</H1>"; $dbhostip = "192.168.0.10"; $dbport = "5432"; $dbname = "testdata"; $dbuser = "postgres"; $dbpass = "password1"; $dbconn = pg_connect($dbhostip,$dbport,$dbname,$dbuser,$dbpass); echo $dbconn; if(!$dbconn) { echo "An error has occurred (line 17)\n"; exit; } $result = pg_query($dbconn, "SELECT * FROM inventory"); if(!$result){ echo "An error has occurred (line 24)\n"; exit; } $resultCheck = pg_num_rows($result); if ($resultCheck > 0) { while ($row = pg_fetch_assoc($result)){ echo $row['cid']; echo $row['item_title']; } } ?> Any help would be appreciated. It seems that anything with $whatever causes the issue... Quote Link to comment https://forums.phpfreaks.com/topic/312703-php-code-breaks-if-any-db-stuff-is-attempted/ Share on other sites More sharing options...
mac_gyver Posted May 14, 2021 Share Posted May 14, 2021 you are either getting a fatal php syntax/parse error or a fatal run-time error. for both of these, get php to help you by finding the php.ini that php is using and set error_reporting to E_ALL and display_errors to ON, so that php will report and display all the errors it detects. stop and start your web server to insure any changes made to the php.ini take effect and use a phpinfo() statement in a .php script file to confirm that the settings took effect. 1 Quote Link to comment https://forums.phpfreaks.com/topic/312703-php-code-breaks-if-any-db-stuff-is-attempted/#findComment-1586562 Share on other sites More sharing options...
maxxd Posted May 15, 2021 Share Posted May 15, 2021 (edited) Your connection string is incorrect. Also, turn on error reporting either in the script or (preferably for local development) in the php.ini. Edited May 15, 2021 by maxxd Quote Link to comment https://forums.phpfreaks.com/topic/312703-php-code-breaks-if-any-db-stuff-is-attempted/#findComment-1586565 Share on other sites More sharing options...
dodgeitorelse3 Posted May 15, 2021 Share Posted May 15, 2021 pg_connect from manualhttps://www.php.net/manual/en/function.pg-connect.php Quote Link to comment https://forums.phpfreaks.com/topic/312703-php-code-breaks-if-any-db-stuff-is-attempted/#findComment-1586567 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.