Jump to content

[SOLVED] "NULL" displaying instead of just blank.


kbata

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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.