0

For some strange and odd reason, wamp is not displaying database errors, and i cant seem to know why, i know it showed error because i have been working with wamp and it displayed errors before, but when i installed it in a new machine recently and started working on it, it was not displaying any database errors,

For example, i was inserting in database tables and the browser was executing the php script and the mysql query but nothing was inserted, after 2 painstaking hours, i found That one of the columns name was wrong, I for a fact remember that mysql displayed a database error telling me that the column does not exist in table, after which i understood the error and corrected it, but now it is not displaying any of it.

code is:

$query = "INSERT INTO campaign (campaignName, campaignPlatform, campaignStatus, 
                                campaignStart, campaignExpiry, campaignText) 
                        VALUES ('{$campaignName}', '{$campaignPlatform}', '{$campaignStatus}', 
                                '{$campaignStartDate}', '{$campaignExpiryDate}', 
                                '{$campaignText}') ";

$result = mysqli_query($con, $query);

Here, campaignStart is actually campaignStarting, the script is processed and the page is blank, but there is no error, no mysql error and no insert on the database, when this happened before, there was always an error from mysql stating "this column does not exist",

Can anyone tell me why this is happening and how to correct it?

RiggsFolly
  • 89,708
  • 20
  • 100
  • 143
Hunain
  • 99
  • 2
  • 8
  • 19
  • may be you did not understand the question at hand, i think there is some config corrections needed to be done for the mysql to show simple errors like the one i mentioned which it used to show on previous machine of mine – Hunain Mar 06 '14 at 05:24
  • 1
    This really depends on your PHP code. If you ignore the errors they wont be shown. Do you get anything in the `php_error.log` – RiggsFolly Mar 06 '14 at 09:03
  • sorry for the late reply, was on break and started discussion with friends, in response to ur reply, please see my question again, the problem is mysql errors are not shown, like i said in my question, errors which were previously shown like "the foo column in test table doesnot exist"; if i have written the name of column wrong are not shown just blank screen – Hunain Mar 06 '14 at 10:48
  • 1
    Please show some sample code containing the PHP code used to access you database. Also is this code you wrote or code you got from somewhere else. – RiggsFolly Mar 06 '14 at 13:17
  • I have edited and inserted the code.... – Hunain Mar 07 '14 at 04:09
  • You should get it with `mysqli_error`. Besides use `error_reporting(1)`. And possible duplicate of: http://stackoverflow.com/questions/17053466/how-to-display-errors-for-my-mysqli-query – Melih Yıldız' Mar 07 '14 at 04:16

2 Answers2

1

All that is returned from a mysqli_query($con, $query); is

Returns FALSE on failure. For successful SELECT, SHOW, DESCRIBE or EXPLAIN queries 
  mysqli_query() will return a result object. 
For other successful queries mysqli_query() will return TRUE. 

So if you want to know about any errors that occur you have to add your own error processing logic.

I assume whatever system you used before had some processing you just didnt bother looking at.

$query = "INSERT INTO campaign (campaignName, campaignPlatform, campaignStatus, 
                                campaignStart, campaignExpiry, campaignText) 
                        VALUES ('{$campaignName}', '{$campaignPlatform}', '{$campaignStatus}', 
                                '{$campaignStartDate}', '{$campaignExpiryDate}', 
                                '{$campaignText}') ";

$result = mysqli_query($con, $query);

if ( ! $result ) {
    printf("Errormessage: %s - %s\n", mysqli_err($con) , mysqli_error($con) );
    exit;
}

// proceed with normal code 

Of course I would formalise this a bit and put all the error processing logic in a function or something so you just need to call a standard function to process any database errors.

RiggsFolly
  • 89,708
  • 20
  • 100
  • 143
0

in my situation it worked after correction of previous script.

mysqli_err($con) > mysqli_error($con)