matt20687 Posted August 26, 2014 Share Posted August 26, 2014 Hey, I have an issue where the below script doesnt appear to be working. It doesnt actually display anything on the page, it seems as though after the first PHP tag is just ignores the rest of the script. when looking at the page source all it shows is: <HTML> <HEAD> <TITLE>Logs</TITLE> </HEAD> <BODY> The actual code is below: <HTML> <HEAD> <TITLE>Logs</TITLE> </HEAD> <BODY> <?PHP $mysqlserver="localhost"; $mysqlusername="root"; $mysqlpassword="test"; $dbname = 'test'; $con=mysqli_connect($mysqlserver, $mysqlusername, $mysqlpassword, $dbname); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $result = mysqli_query($con, "SELECT * FROM forwardtable"); echo "<table border='1'> <tr> <th>Acc Num</th> <th>Send Date</th> <th>Send Time</th> </tr>"; while($rowContent = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $rowContent['Acc'] . "</td>"; echo "<td>" . $rowContent['Date'] . "</td>"; echo "<td>" . $rowContent['Time'] . "</td>"; echo "</tr>"; } echo "</table>" ?> </BODY> </HTML> If I remove the PHP from within the code the source code goes as it should and shows the </BODY> and </HTML> tags. Any ideas anyone? Thanks, Matt Quote Link to comment https://forums.phpfreaks.com/topic/290659-phpsql-nightmare/ Share on other sites More sharing options...
cyberRobot Posted August 26, 2014 Share Posted August 26, 2014 Do you have PHP errors enabled and set to be shown? You can add the following to the top of your script to show all PHP errors and warnings: <?php //REPORT ALL PHP ERRORS error_reporting(E_ALL); ini_set('display_errors', 1); ?> Of course, you'll want to remove the above debugging once the issue has been resolved. Also, note that the last echo statement in your code is missing a semi-colon. echo "</table>" Quote Link to comment https://forums.phpfreaks.com/topic/290659-phpsql-nightmare/#findComment-1488967 Share on other sites More sharing options...
matt20687 Posted August 26, 2014 Author Share Posted August 26, 2014 (edited) Okay, the error is on line 13. Could it be the way I am connecting to the SQL DB? The server is using PHP 5.2.1. Edited August 26, 2014 by matt20687 Quote Link to comment https://forums.phpfreaks.com/topic/290659-phpsql-nightmare/#findComment-1488971 Share on other sites More sharing options...
cyberRobot Posted August 26, 2014 Share Posted August 26, 2014 Okay, the error is on line 13. Could it be the way I am connecting to the SQL DB? Perhaps, what is the error message? Quote Link to comment https://forums.phpfreaks.com/topic/290659-phpsql-nightmare/#findComment-1488975 Share on other sites More sharing options...
matt20687 Posted August 26, 2014 Author Share Posted August 26, 2014 Hey, The error is: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test\test.php on line 13 It does the same for mysqli. Quote Link to comment https://forums.phpfreaks.com/topic/290659-phpsql-nightmare/#findComment-1488980 Share on other sites More sharing options...
CroNiX Posted August 26, 2014 Share Posted August 26, 2014 That only happens if you don't have mysql (don't use that) or mysqli extension enabled in php. Quote Link to comment https://forums.phpfreaks.com/topic/290659-phpsql-nightmare/#findComment-1488981 Share on other sites More sharing options...
mikosiko Posted August 26, 2014 Share Posted August 26, 2014 (edited) this small script should show you which extensions you have enabled (among others things) <?php phpinfo(); ?> if mysql , mysqli and/or pdo is enabled you should see them on the display... if not, then you must enable them in your php.ini.. on it look for this lines ;extension=php_mysql.dll ;extension=php_mysqli.dll ;extension=php_pdo_mysql.dll and if the semicolon is present just delete it... otherwise be sure that your extension_dir is properly configured in the same php.ini. remember to re-start Apache after your modify your php.ini Edited August 26, 2014 by mikosiko Quote Link to comment https://forums.phpfreaks.com/topic/290659-phpsql-nightmare/#findComment-1488982 Share on other sites More sharing options...
matt20687 Posted August 26, 2014 Author Share Posted August 26, 2014 I have checked and they were all commented out, I have done this and restarted apache. I am trying to use PDO now but that hasnt worked either just states the PDO class is not found :S Quote Link to comment https://forums.phpfreaks.com/topic/290659-phpsql-nightmare/#findComment-1488983 Share on other sites More sharing options...
mikosiko Posted August 26, 2014 Share Posted August 26, 2014 I have checked and they were all commented out, I have done this and restarted apache. I am trying to use PDO now but that hasnt worked either just states the PDO class is not found :S and what about the results of the suggested script... look also for the "Loaded Configuration File" in that result to be sure that you are loading the right php.ini <?php phpinfo(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/290659-phpsql-nightmare/#findComment-1488984 Share on other sites More sharing options...
matt20687 Posted August 26, 2014 Author Share Posted August 26, 2014 (edited) and what about the results of the suggested script... look also for the "Loaded Configuration File" in that result to be sure that you are loading the right php.ini <?php phpinfo(); ?> It is def opening the correct .ini file. As far as extensions go, I cannot find anything to do with PDO however mssql is enabled, could this be used? Never used it before tho.... Edited August 26, 2014 by matt20687 Quote Link to comment https://forums.phpfreaks.com/topic/290659-phpsql-nightmare/#findComment-1488985 Share on other sites More sharing options...
CroNiX Posted August 26, 2014 Share Posted August 26, 2014 Can't use mssql (Microsoft SQL) unless you have their database server installed, and I wouldn't recommend doing that. I'd look in your php extension directory and see if php_pdo_mysql.so (or .dll if windows) is present, if so just add the line to your php.ini like the others. Quote Link to comment https://forums.phpfreaks.com/topic/290659-phpsql-nightmare/#findComment-1488987 Share on other sites More sharing options...
mikosiko Posted August 26, 2014 Share Posted August 26, 2014 Unfortunately we are not able to see your screen or your results, but if you are not seeing the mysql, mysqli or pdo extensions enabled in the phpinfo() results most likely those are not enabled in your php.ini file, or the extension_dir is incorrect, or the extensions are not present on it, or you setup is loading an incorrect php.ini... you must review your configuration in details... we can't. Did you install Apache, PHP, Mysql manually yourself?... or are you using some of the LAMP's availables? (WAMP XAMP, AMPPS, etc.)... maybe you should go that route which is normally the easier one. Quote Link to comment https://forums.phpfreaks.com/topic/290659-phpsql-nightmare/#findComment-1488988 Share on other sites More sharing options...
matt20687 Posted August 26, 2014 Author Share Posted August 26, 2014 Can't use mssql (Microsoft SQL) unless you have their database server installed, and I wouldn't recommend doing that. I'd look in your php extension directory and see if php_pdo_mysql.so (or .dll if windows) is present, if so just add the line to your php.ini like the others. Hi, I have looked and there is no ext called php_pdo_mysql.dllI have: php_mssql.dll php_sybase.dll php_win32service.dll php_zip.dll Unfortunately it was not me who installed Apache and MYSQL, this was done years ago by a provider that we use for an application that is running on there. They do not have a local database, it connects to a central one. Can I add in php_pdo_mysql.dll to the ext directory? If so where can I get the dll from? Quote Link to comment https://forums.phpfreaks.com/topic/290659-phpsql-nightmare/#findComment-1488989 Share on other sites More sharing options...
CroNiX Posted August 26, 2014 Share Posted August 26, 2014 Likely no. The extension needs to be from the same version of php. I'd reinstall php from scratch. You will likely need a more modern version anyway if it was installed "years ago". Since it doesn't sound like you have messed with this stuff much, I'd take mikosiko's advice and use WAMP, which will install a current Apache/MySQL/PHP stack all at once, and they will all work together because it's made to. Quote Link to comment https://forums.phpfreaks.com/topic/290659-phpsql-nightmare/#findComment-1488990 Share on other sites More sharing options...
matt20687 Posted August 26, 2014 Author Share Posted August 26, 2014 Hmm this has just gotten a bit more complicated that I wanted! I may have to think about doing this a different way, basically I have a tricky situation where I cannot change the PHP or Apache version due to the current application thats on there requiring the version it has already. Bit crappy really! Quote Link to comment https://forums.phpfreaks.com/topic/290659-phpsql-nightmare/#findComment-1488991 Share on other sites More sharing options...
mikosiko Posted August 26, 2014 Share Posted August 26, 2014 Before to start looking for that extension (or any other) you must find out which PHP version are you running, and if it is the "thread safe" version or not (most likely will be)... again phpinfo() will give you a lot of that information; with that information on hand you could start looking for that specif version of PHP on http://windows.php.net/download/ ; look for the zipped version...download and unzip it in a temporary directory (NOT IN YOU CURRENT PRODUCTION DIR OBVIOUSLY) and look for the extensions that you want... copy/paste what you need in your current PHP extension directory and test restarting apache and see if the extension is loaded correctly...if not will mean that you downloaded the wrong PHP version most likely... good luck Quote Link to comment https://forums.phpfreaks.com/topic/290659-phpsql-nightmare/#findComment-1488993 Share on other sites More sharing options...
jazzman1 Posted August 27, 2014 Share Posted August 27, 2014 Before to start looking for that extension and self-modifying code, make sure you've got a full back up By the way, is it possible to have multiple versions of php on the same windows server? I'm not familiar with windows at all, but on my RedHat machine I've got 3 different versions of php-4.1.0, 5-1.6 and 5-3.3. Quote Link to comment https://forums.phpfreaks.com/topic/290659-phpsql-nightmare/#findComment-1489012 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.