Jump to content

PHP/SQL Nightmare


matt20687

Recommended Posts

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

Link to comment
Share on other sites

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>"
Link to comment
Share on other sites

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 by mikosiko
Link to comment
Share on other sites

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();
?>
Link to comment
Share on other sites

 

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 by matt20687
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.