First, I am not a PHP coder. The PHP pages I use to generate PDF files were written with the help of others! This script was running just fine, no errors, etc., spitting out the PDFs just as nice as can be. However, now it is giving me the following error:
[Microsoft][ODBC Microsoft Access Driver]Invalid use of null pointer PHP Notice: Undefined variable: pdfinfo in C:\hshome\wxxxxxe\mxxxxds.com\labels_PDF.php on line 18 PHP Notice: Undefined variable: pdfinfo in C:\hshome\wxxxxxe\mxxxxds.com\labels_PDF.php on line 19 PHP Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access Driver]Invalid use of null pointer , SQL state S1009 in SQLExecDirect in C:\hshome\wxxxxxe\mxxxxds.com\labels_PDF.php on line 19
I haven’t changed anything in the code or the database, etc. The only change was whatever took place when win2 server was reloaded after crashing yesterday. Is this error something I should look for and fix in my code, or is there a setting I need to have tech support look at?
Just in case, here is the code:
<?php
define('FPDF_FONTPATH','PDF/font/');
require_once('PDF/PDF_Label.php');
$odbc = odbc_connect ('databasename', 'root', '') or die( "Could Not Connect to ODBC Database!" );
if(!($pdfinfo == "nada")){
$query = odbc_exec($odbc, stripslashes($pdfinfo)) or die (odbc_errormsg());
$pdf2 = new PDF_Label('5160', 'mm', 1, 2);
$pdf2->Open();$pdf2->AddPage();
// Print labels
while($Row=odbc_fetch_array($query)){$pdf2->Add_PDF_Label(sprintf("%s\n%s\n%s\n%s, %s, %s", "", "$Row[Firstname] $Row[Lastname]", "$Row[Address1] $Row[Address2]", "$Row[City]","$Row[State]","$Row[Zip]"));}$pdf2->Output();
}
?>
OK, it’s been over 24 hours and no answer here after I reposted. I sent a ticket in and, at their request, even created a test user and password over 12 hours ago so the techs could sign in and see for themselves. No response yet. This is ridiculous. Anybody got any suggestions for a hosting company with qualified tech support?
I have found and fixed the problem. Not being a PHP coder, I was stumped as to why the code would work prior to the crash, and not work after the crash. It all boiled down to the “register_globals” setting - prior to the crash it must have been “on”, and after the crash it was left to the default “off”.
Because “register_globals” is off, my variable syntax was wrong. Before, I was using the variable coming from the form like this: $variablename.
I have rewritten the code to this: $_POST[‘variablename’]
The only announcement I see that MAY apply was back in April. If this had been implemented in April, I would have been getting the errors before the win2 crash. My script was written for me about 10 days before the crash, 2 1/2 months after the announcement should have taken effect, and it worked fine. A very experienced PHP coder wrote it for me and tested it as well. Was it a fluke? I have no idea. As I originally pointed out I am not a PHP coder, so I had no clue what to look for, and just happened to find the answer through dogged determination. I am just glad I found the answer.