kbata Posted June 28, 2009 Share Posted June 28, 2009 I have been trying to move a mysql database and php web site from my local computer to another server. When pages are served from my local computer if a field has no value nothing is displayed. Now on the new server wherever there is no information in a field "NULL" is displayed. How can I get it so that if a field is blank nothing displays? Is this a setting in the php configuration file or is the problem with mysql? Quote Link to comment https://forums.phpfreaks.com/topic/163977-solved-null-displaying-instead-of-just-blank/ Share on other sites More sharing options...
MadTechie Posted June 28, 2009 Share Posted June 28, 2009 It could be either, it really depends on your system, IE your database could be different (the field could be NULL on one and NOT NULL on the other) Quote Link to comment https://forums.phpfreaks.com/topic/163977-solved-null-displaying-instead-of-just-blank/#findComment-865050 Share on other sites More sharing options...
fenway Posted June 28, 2009 Share Posted June 28, 2009 I'm not sure what you mean.... what's stored in the DB? NULL or ""? Besides, mysql has no control over how anything is displayed -- that's up to you in PHP/HTML. Quote Link to comment https://forums.phpfreaks.com/topic/163977-solved-null-displaying-instead-of-just-blank/#findComment-865054 Share on other sites More sharing options...
kbata Posted June 28, 2009 Author Share Posted June 28, 2009 The system set up that works is on OS X Leopard. PHP version 5.2.9 mysql version 5.1.33, Apache 2.2.11 The other is a Linix system using PHP v 5.2.8 Apache 2.2.3, mysql 5.0.45 In both databases the fields are set to allow null and default to null. In the setup from my mac when pages are viewed null is not displayed. If it's a case where null needs to be cleared out is there an easy way to do this for all null fields? When I view the both databases using phpmyadmin null is shown for fields with no value. When I look at my web pages when served from my computer null fields are just displayed blank which is what I want. Quote Link to comment https://forums.phpfreaks.com/topic/163977-solved-null-displaying-instead-of-just-blank/#findComment-865214 Share on other sites More sharing options...
MadTechie Posted June 28, 2009 Share Posted June 28, 2009 can you post the code that displays the data Quote Link to comment https://forums.phpfreaks.com/topic/163977-solved-null-displaying-instead-of-just-blank/#findComment-865232 Share on other sites More sharing options...
kbata Posted June 29, 2009 Author Share Posted June 29, 2009 <h2>Orders</h2> <?php If($total_count < 1){ echo $message = "No orders were found."; } else { echo "Records Found: $found_count, Viewing records $first_record to $last_record <br />" ; ?> <table cellpadding="5" cellspacing="2" class="page_content" id="inventory"> <tr> <th>Client</th> <th>System Order #</th> <th>Order Date</th> <th>Ship Company</th> <th>Ship Name</th> <th><div align="left">Ship Address</div></th> <th><div align="center">Ship City</div></th> <th><div align="center">Ship State</div></th> <th><div align="center">Ship Zip</div></th> <th>code</th> <th><div align="center">Order Status</div></th> </tr> <?php } ?> <?php foreach($orders as $order): ?> <tr> <td><?php echo $order->client_id; ?></td> <td><?php echo "<a href=order_detail.php?id=". urlencode($order->system_order_id) . ">". $order->system_order_id ."</a></li>"; ?></td> <td nowrap="nowrap"><?php echo date_us($order->order_date); ?></td> <td><?php echo $order->ship_company; ?></td> <td><?php echo $order->ship_first . " " . $order->ship_last; ?></td> <td><div align="left"><?php if(!empty($order->ship_address_2)){ echo $order->ship_address_1 . "<br />" . $order->ship_address_2; } else {echo $order->bill_address_1; } ?> </div></td> <td><div align="left"> <?php echo $order->ship_city; ?> </div></td> <td><div align="center"><?php echo $order->ship_state; ?></div> <div align="center"></div><div align="center"></div><div align="center"></div></td> <td><div align="center"><?php echo $order->ship_zip ?></div> <div align="center"></div></td> <td><?php echo $order->status_code; ?></td> <td><div align="left"><?php echo $order->status_name; ?></div></td> </tr> <?php endforeach; ?> Quote Link to comment https://forums.phpfreaks.com/topic/163977-solved-null-displaying-instead-of-just-blank/#findComment-865560 Share on other sites More sharing options...
kbata Posted June 30, 2009 Author Share Posted June 30, 2009 I'm really surprised there isn't an easy answer to this. Do people actually want to have Null displayed when fields have no value? I have tried using phpmyadmin to have the default value be blank while still allowing the field to be blank with no luck. It seems crazy to need to put something in the php code that determines if there is a non null value to display. Quote Link to comment https://forums.phpfreaks.com/topic/163977-solved-null-displaying-instead-of-just-blank/#findComment-866338 Share on other sites More sharing options...
kbata Posted June 30, 2009 Author Share Posted June 30, 2009 I figured it out! When I was browsing using phpmyadmin both my internal database and the remote one looked like they had identical information with NULL displayed in empty fields. The difference was that when I went to edit the record on my internal db null was checked off while with the remote db NULL was entered in the edit box. I'll just delete the data and try the import again using an sql export file instead of a csv. Quote Link to comment https://forums.phpfreaks.com/topic/163977-solved-null-displaying-instead-of-just-blank/#findComment-866364 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.