If Null

I'm sure this is very simple, but I'm just getting started with php and mysql and was wandering if someone could help me with a snipped of code.
I have a page that displays information from my database. One of the items it displays is an image. like this:

<img src="<?php echo $row_Businesses['logo_url']; ?>" alt="<?php echo $row_Businesses['name']; ?>" width="100" height="100" border="1" />

Now, not all of the rows in my database have an entry for 'logo_url' and are null. I would like it so that if 'logo_url' is null it will instead show an alternative image called nologo.gif

I imagine it would be along the lines of if 'logo_url' = null show nologo.gif else show <?php echo $row_Businesses['logo_url']; ?>.



ADVERTISEMENT

Zend Framework: Filter Input, Turning Zero To Null, Then Validate Null?

So I've determined that my validator does not get called when I filter the input value and turn zero into null.

$this->addElement('select', 'State_ID', array('label' => 'State', 'multiOptions' => $this->getStates(), 'validators' => array($requiredBasedOnCountry), 'filters' => array($makeZeroNull)));

[code]....

The reason I am doing this is because I don't want to insert 0 into the database.When I call getValues()on the form, I don't want to have to change each one manually.But I want to also validate the input.How can I filter the value, and also validate it?

View 1 Replies View Related

Sort Multidimensional Array Values From Not Null To Null?

I want to sort multidimensional array values from not null to null. I want to sort my multidimensional array if the address fields like street, post numbers are null then they should display in last page.

View 2 Replies View Related

$_FILES Is Null, $_POST Is Not Null?

upload a file, my $_POST variable knows the file name, but the $_FILES variable is null.I've used this code before, so I'm really stumped.Here's what I'm using for input:

<label for="importFile">Attach Resume:</label>
<input type="hidden" name="MAX_FILE_SIZE" value="10000000">
<input type="file" name="importFile" id="importFile" class="validate['required']">

[code]...

And for processing:
$uploaddir = "E:/Sites/OPL/2008/assets/apps/newjobs/resumes/";
$uploadfile = $uploaddir . time() . '-' . urlencode(basename($_FILES['importFile']['name']));

[code]...

Which is giving me this result:Error uploading file. Error number:NULL
Maintaining The OPL Website.doc

View 3 Replies View Related

Zero And NULL

I have the following switch statement:

switch ($record->sub_page) {
case -1:
$this->page = 6;
$error_message = '<center>You appear to have already completed the
form.</center>'
break;
case 0:
$this->page = 5;
ff_query("UPDATE #__gateway_form_1 SET `sub_page`=-1 WHERE
userid=$my->id and `expiry_date` = '$expiry_date'");
break;
default:
do something else
}

The value of $record->sub_page can be NULL. If it is NULL, the case for 0
seems to fire. I really need the default action to happen when
$record->sub_page is NULL or a +ve value.

However if I do:

switch ($record->sub_page) {
case -1:
$this->page = 6;
break;
case NULL:
do something else;
break;
case 0:
$this->page = 5;
break;
default:
do something else;
}

then the switch manages to tell the difference between a NULL and a zero.

Is it correct that php treats NULL as 0?

View 13 Replies View Related

NULL Or NOT NULL

I'm using GROUP BY in a MySQL query to return rows of scores based on the values held in a field. The query prints the value that applies to each row, and then the score - the number of records with that value. It works, but I'm finding that one of the rows shows no value but does show a score, as if there are some empty cells in the database (there are too many results to be able to go into the database and actually see those empty cells).

Whether I reset the field to NULL or NOT NULL (in phpMyAdmin) makes no difference - the empty cell score is displayed either way. Seems odd to me, so I am trying to get a better understanding of when to specify NULL and NOT NULL and how to construct a query in such a way as to exclude cells with no data. Technically, if I want to exclude results where a cell contains no data, what combination should I be using?

Currently my query is ....

View 1 Replies View Related

What Happens If Null?

What happens if one or more of my variables are not set or empty when I use an INSERT statement for a mySQL db?

$query="INSERT INTO log (ipaddress,date,time,kid,sid) VALUES ('$ipaddress','$date','$time','$kid','$sid')";

Will the INSERT statement fail or does it just leave a blank in that field?

View 3 Replies View Related

(NULL+X)?

Is it possible to setup a mysql insert that instead of just inputting 'NULL' allows me to do something like 'NULL+10' (it takes the next number and then adds 10 to the db entry)?

View 1 Replies View Related

Null Value

I have a php code for two combo box: the selection of the first one is
the condition for what it will show on the second one. The page is located at:

http://www.historiadelpais.com.ar/p...s_argentina.php

I have two problems:

1) At the first time that someone enter this page, as nothing is
selected in the first combo, the page shows the error:

Warning: Supplied argument is not a valid MySQL result resource in
/home/sites/site66/web/provincias/pueblos_argentina.php on line 162

This error disappeared when something is selected in the first
combobox an press the button to reload the page.

2) Is there a posibility to recover the values of the second combo box
without reload the page?

View 1 Replies View Related

'NULL' The Same As NULL

I've looked around on the web for this, but can't find a definitive answer. In any case, when I am inserting values into a MySQL database, would:

INSERT INTO table (column) VALUES (NULL)

be the same as

INSERT INTO table (column) VALUES ('NULL')

I've tried both versions out on int columns to make sure the latter is not just being treated as a string and they seem to work.

View 3 Replies View Related

$var = 'NULL'

I am trying to create a series of if statements. If the var is equal to null it should update the db. If it is not equal to null and has a value it should go to the next if statement. I have tried if ($var = 'NULL") and it always lets me write to the db even if there is a greater value there. I have tried if($var == 'NULL') and it never lets me write to the db no matter what value is in the db. I have also tried each of these with = '0' instead of null.

View 8 Replies View Related

How Does NULL Work?

Here's what I have:

A table with several rows. Each row has 11 columns... The first column is the unique ID. The remaining ten are varchar columns meant to hold the filename of a given image (for instance [primarykey]1.jpg, [primarykey]2.jpg, etc.) I then have a javascript photo browser, where each photo name is loaded dynamically into a list with a repeating region assigned:

<option name="<php code here>">

This all works fine, however, not all rows have 10 photos. So, I need to know how NULL works. Can I code my option list so that it will not insert another entry if the corresponding field is NULL?

View 1 Replies View Related

What Is Better As A Default Value: NULL Or ''?

I would like to collect some statistical data and then make some reports on it. I'm creating tables for this task and i'm not sure what is better for filling default values: NULL or ''. What is optimal for storage purposes and for further reports creation?

View 1 Replies View Related

Argv[0] Always Null

In my PHP, argv[0] always return correct value.
In a remote server, PHP returns for argv[0] always null.
I believe this is a "php.ini" problem but from PHP help I don't found
anything.

1. What is the problem?
2. How to fix it? (or...)
3. With what I can replace argv[0]?

View 1 Replies View Related

Differentiate Between NULL And 0

I have a script which takes the results of a form and updates or creates
a record in a db table. So far so dull. It works fine, except when I
leave certain fields blank; these are entered in the table as zero
values. Can anyone assist me to differentiate between NULL and zero? the
variables that are troubling are fatalities, injuries, latitude and
longitude.

code:

# load variables into array
$variables["type"] = $type;
$variables["location"] = $location;
$variables["fatalities"] = $fatalities;
$variables["injuries"] = $injuries;
$variables["latitude"] = $latitude;
$variables["longitude"] = $longitude;
$variables["development"] = $development;
$variables["list"] = $list;
$variables["display"] = $display;
$variables["description"] = $description;

foreach ($variables as $key => $value) {
# loop through variables;
$element =& $variables[$key];
if (isset($value)) {
# if variable is not null, add quotes for sql query
$element = "'" . $element . "'";
} else {
# variable is NULL - no quotes
$element = "NULL";
}
unset($element);
}

# explode array back to variables
extract($variables);

if(isset($eventID)) {
# updating an existing record
# create SQL from variables
$sql = "
UPDATE tblevents
SET enumType = $type,
locationID = $location,
datDate = '$eventDate',
intFatalities = $fatalities,
intInjuries = $injuries,
dblLatitude = $latitude,
dblLongitude = $longitude,
developmentID = $development,
enumList = $list,
enumDisplay = $display,
txtDescription = $description
WHERE eventID = $eventID
";
}

View 4 Replies View Related

Assigning A Null Value

I have a set of radio buttons labelled 1-5 and a 'not selected' option which I have coded as 6. I later use responses of 1-5 to calculate a score, but at the moment the 6 is included in that score when it should really be excluded as null.

Is there a way to tell PHP that any values of &#396;' should be null, and to use &#393;' instead?

View 1 Replies View Related

Inserting NULL

I have this sql but when it runs certain values should be coming in as NULL but instead there is just a blank area in the database.

So later when i run a if isset statement it gets everything. How can i have those values where nothing was entered on the form coming in as null.

$obstacle_insert = "INSERT INTO `obstacles` (`spot_id` , `rails` , `steps` , `ledges`, `gaps` , `drops`, `manuals`) VALUES ($spot_id, '$rails', '$steps', '$ledges', '$gaps', '$drops', '$manuals')";

$obstacle_result = mysql_query($obstacle_insert) or die (mysql_error());

View 3 Replies View Related

If Varbile Is Not Null

am indeed relativly new to this php, but learning quick, and having lots of fun in the process, but ive been stumped here. All i need is the syntax for a null requirement in an if statement, ive tried all sorts, with no luck. So i have..

If ($row_nicheresults['Region'].... then i need does not equal a null value.

Firstly, does this makes sense?

View 3 Replies View Related

Default To NULL

table product

products_id, products_name, icon_1, icon_2.

table icon

icons_id, icons_name

When I display a product, I may display some icons (0-2) with that product. So I have the above produc and icon table set up. In the product table, icon_1 and icon_2 will hold the icons_id from table icon, if there is an icon at that position.

icons_id is smallint (Auto Increment key value).

To me it is the same. Both value will never be the icons_id of table icon, which will mean no icon will be shown.

What is your suggestion? In general, in this case, the samillint value will not be used in any calculation, only will be used to refer to another tables auto increment key. When it is EMPTY, should I set it to 0 or should I set it to NULL?

View 8 Replies View Related

Isset And NULL

When my webhost upgraded from PHP 4 to PHP 5, I had to change this:

if (isset($button)) {
//do something
}

...to this:

if (isset($button) && $button!=NULL) {
//do something
}

1.) Can anyone explain why I had to do that?
2.) Does this have to do with PHP 5?
3.) Will all my isset functions need to be paired with a, "!=NULL" ??
4.) Is there a better way to do this?

The code for the form I used was:
<FORM METHOD="POST" ACTION="nextpage.php">
<INPUT TYPE="submit" NAME="button" VALUE="Submit">
</FORM>

View 3 Replies View Related

Null Value Calulation

I have a form with 2 text boxes and a button that calls a php calculation and displays the result. I want to have it so that if it returns a zero or a null it displays nothing. If the user leaves the text boxes blank the result of the php if statment returns the number 0. If the user inputs 0's into the text boxes it returns nothing as expected.

If the user inputs numbers it displays "value = 67.98" . I can't figure out where 0 is comming from as the if statement is not being fulfilled so it shouldn't be displaying anything. Here is the code for the calculation

$item2tot = floatval ($POST['item2']) * floatval ($POST['qty2']);

Here is the code for the if statement

<?php if ($item2tot != &#390;'){ echo "value = $item2tot" ;} ?>

View 6 Replies View Related

Ignore Null

is there away i can ingnor blank values in a insert from a php? I have a loop that inserts a bunch of records but its possible that some can be empty so I dont want to insert empty ones. Can anyone help please?

View 1 Replies View Related

Want To Select All NOT NULL

Select fields "user_from, username, user_email FROM database phpusers where user_from does NOT contain "USA" nor are BLANK, and then order by username.

My PHP script is :

$sql = "SELECT user_from, username, user_email FROM phpbb_users WHERE user_from NOT LIKE '%usa%' OR user_from=NULL OR user_from='' ORDER BY username";

//Execute SQL query
$sql_result = mysql_query($sql,$conn) or die(mysql_error());


It seems to be selecting all those without "USA" which is what I want, however seems to be ignoring the part about NOT wanting to select those that are BLANK (NULL).

View 1 Replies View Related

NULL Values

here's a snippet from one of my php files:

if ($list['PRODUCT'] >= 0) {
        $product = number_format ($list['PRODUCT']);
    } elseif ($list['PRODUCT'] == NULL) {
        $product = '?'
    }

I want the page to display a ? sign if the value in the mySQL table is NULL (which it clearly shows as NULL) yet it ends up displaying 0 all the time. If I change the >= to just >, then it displays correctly.

I thought 0 was something entirely different than NULL. The mySQL field is INT(8) with NULL set to yes, and with 0 as the default.

View 14 Replies View Related

Will Not Insert NULL

I am trying to insert items into a database and if the user has not entered anything in the field then i want the database to register NULL. This is'nt happening. Code:

View 1 Replies View Related

0 = NULL Problem

I am making an administration for our dogschool with PHP and MySQL Now I'm trying to make a page for the lessons per hour, day and kind.

That all works okay, exept for the hour-thing If I put down '%9%' by SELECT , it works fine, but when I put down '%10%' it doesn't work. I think MySQL has a problem with the 0 and the 1.

The field Lesson is one textfield where Kind, Hour, Place, Day and Instructor are all typed behind eachother, like this: A 10.00 hr Tilburg Saturday Tom

This is what I have 'till now, and it works great if the last 10 is a 9, but if there's a 0 or a 1 in the syntax, it starts coughing Code:

View 6 Replies View Related

Query If Null, Then... If Not Null, Then New Query

I would like to be able to query a table, if the employee_start is null, then I would like to query another table to get the list of all employees into a select list, if it is not null, then I would like it to put the employee_start as an echo in a text box. I am wondering if this can be done. Code:

View 8 Replies View Related

Fields Must Not Be Null

If one of the fields is not filled in I want a message to come up and say "all fields must be filled in" when the button is clicked and a field is NULL. Any idea what code i would put in here for that to happen? Code:

View 4 Replies View Related

Querying NULL

I have a simple query question about getting all records with NULL in the field. This is what I've been trying: PHP Code:

SELECT * FROM tbl WHERE column = 'NULL'

But it keeps returning 0 records. How do I select all records with NULL in the field? If there was a zero, or another number, that would be easy, but in this case, I can't select all rows that have NULL in one column. Also, I want to filter my results a little more than that.

View 3 Replies View Related

Return NULL

I have a few fields in db tables that are set to NULL, however if I post a form and that updates that table it'll change the NULL to whatever value corresponds. Now, I need to be able to change it back to NULL if a user updates the form and clears the form field or puts a space in it.

View 6 Replies View Related

Int Default NULL And O?

What is the difference for "int" type if default is NULL or o?

View 14 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved