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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

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.

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.