Jump to content

[SOLVED] mysql_error() returning nothing


nbarone

Recommended Posts

<select name="viewGroup">
<?php
$query = "SELECT * FROM sg09_groups WHERE group_display=1";
$result = mysql_result($query) or die (mysql_error());
while($row = mysql_fetch_array($result)){
echo "<option value=\"".$row['group_id']."\">".$row['group_name']."</option>";
}
?>
</select>

 

 

this code is dying, but not returning a mysql_error() .....

 

if I do....

$result = mysql_result($query) or die (mysql_error()."test");

it will return "test"

Link to comment
https://forums.phpfreaks.com/topic/153340-solved-mysql_error-returning-nothing/
Share on other sites

Add the following two lines immediately after your first opening <?php tag -

 

ini_set ("display_errors", "1");
error_reporting(E_ALL);

 

Edit: And the posted code does not have a mysql_query() statement in it, which the error you will get by adding the above two lines will point out.

 

You should be learning php, developing php code, and debugging php code on a system where error_reporting is set to E_ALL and display_errors is set to ON in your php.ini.

With error reporting turned on, like PFMaBiSmAd mentioned, this could have been easily detected.

 

I do agree, it is always the little things...

 

Mark as [sOLVED] please, thanks!

 

I agree with the error reporting comment, however I am not the system admin and it is globally turned off. The onyl way I can access errors is to remote directly to the webserver. After doing that I must open the PHP file in cmd prompt.

I agree with the error reporting comment, however I am not the system admin and it is globally turned off. The onyl way I can access errors is to remote directly to the webserver. After doing that I must open the PHP file in cmd prompt.

 

No, you can temporarily turn them on with these lines of code:

 

ini_set ("display_errors", "1");
error_reporting(E_ALL);

You should be learning php, developing php code, and debugging php code on a local PC, where you would have access to the master php.ini.

 

You can also set those two settings in a .htaccess file (when php is running as an Apache module, you must use the numeric equivalent of E_ALL), in a local php.ini (when php is running as a CGI application), or in your script (using the two lines of code that was posted) but this last option won't show fatal parse errors.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.