elentz Posted November 9, 2008 Share Posted November 9, 2008 I have two questions. The first is can someone see why I would get a blank page when I run this code? I know there is info in the table, because I can run this query in Myphpadmin and get a result. <?php include("conn.php"); //$query = "select field1, fieldn from table [where clause][group by clause][order by clause][limit clause]"; $query = "SELECT vtiger_invoice.accountid, vtiger_invoice.invoice_no, vtiger_invoice.invoicestatus, vtiger_invoice.subject, vtiger_invoice.total, vtiger_invoice.invoicedate, vtiger_invoicecf.cf_674 FROM vtiger_invoice Inner Join vtiger_invoicecf ON vtiger_invoicecf.invoiceid = vtiger_invoice.invoiceid WHERE vtiger_invoice.accountid = 17683 ORDER BY vtiger_invoice.accountid ASC"; $result = conn($query); if (($result)||(mysql_errno == 0)) { echo "<table width='100%'><tr>"; if (mysql_num_rows($result)>0) { //loop thru the field names to print the correct headers $i = 0; while ($i < mysql_num_fields($result)) { echo "<th>". mysql_field_name($result, $i) . "</th>"; $i++; } echo "</tr>"; //display the data while ($rows = mysql_fetch_array($result,MYSQL_ASSOC)) { echo "<tr>"; foreach ($rows as $data) { echo "<td align='center'>". $data . "</td>"; } } }else{ echo "<tr><td colspan='" . ($i+1) . "'>No Results found!</td></tr>"; } echo "</table>"; }else{ echo "Error in running query :". mysql_error(); } ?> I do have a conn.php file in the same folder as where this is being run from. I got this code from another site as an example. The only changes I made were the query and the conn.php file. My second question is with TCPDF and if anyone can answer this. I want to have this table info incorporated into a PDF I want to create. Thanks alot for any help! Quote Link to comment Share on other sites More sharing options...
trq Posted November 9, 2008 Share Posted November 9, 2008 Change... if (($result)||(mysql_errno == 0)) to.... if (($result) && (mysql_errno() == 0)) Quote Link to comment Share on other sites More sharing options...
elentz Posted November 9, 2008 Author Share Posted November 9, 2008 Thanks for the speedy reply! And the suggestion, but I still get the same thing, a Blank Screen. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 9, 2008 Share Posted November 9, 2008 Is this on a server where you know that the mysql extension is enabled in php? Or is this like the first time you have tried to execute any mysql functions in php? Quote Link to comment Share on other sites More sharing options...
elentz Posted November 9, 2008 Author Share Posted November 9, 2008 This is on a server that is running Vtiger and I have a similar script showing the same query using Baagrid. I want to create a PDF with TCPDF and I have never created a table from a query before so I was testing.. I can't even get a look at the source with Firefox when I have this loaded. I have tried a different browser as well. If my conn.php file is in the same directory all I need to have is the "conn.php" and not something like "..//conn.php" right? Quote Link to comment Share on other sites More sharing options...
trq Posted November 9, 2008 Share Posted November 9, 2008 Make sure error reporting is enabled by placing the following at the top of your script. <?php error_reporting(E_ALL) ; ini_set('display_errors', '1'); ?> Also, what does your conn() function look like? Quote Link to comment Share on other sites More sharing options...
elentz Posted November 9, 2008 Author Share Posted November 9, 2008 I got an error for this line "$result = conn($query);" Fatal error: Call to undefined function conn() in /var/www/cqicrm5/customstuff/statement2.php on line 23 Quote Link to comment Share on other sites More sharing options...
elentz Posted November 9, 2008 Author Share Posted November 9, 2008 Sorry I forgot to give you my conn.php <?PHP //****************************************************** // Connection to the Database //****************************************************** $conn = mysql_connect("localhost", "admin", "password"); mysql_select_db ('vtigercrm50',$conn); //****************************************************** ?> Quote Link to comment Share on other sites More sharing options...
bobbinsbro Posted November 9, 2008 Share Posted November 9, 2008 soooooooo.... why are you calling the nonexistent function conn()? Quote Link to comment Share on other sites More sharing options...
elentz Posted November 9, 2008 Author Share Posted November 9, 2008 Probably a noobie mistake. I have always included my connection in my script, but I got this one online and didn't change it, just created the conn.php. So what kind of change should I make? Quote Link to comment Share on other sites More sharing options...
trq Posted November 9, 2008 Share Posted November 9, 2008 You need to change.... $result = conn($query); to... $result = mysql_query($query); Quote Link to comment Share on other sites More sharing options...
elentz Posted November 9, 2008 Author Share Posted November 9, 2008 Thanks that is working!! Is there a way to make the table column headers more to my liking? Right now they show the field names from MySql. Thanks again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.