If Null

Aug 8, 2007

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="<?phpecho$row_Businesses['logo_url'];?>" alt="<?phpecho$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?

Jun 17, 2010

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?

Jun 1, 2011

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?

Mar 24, 2010

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

Jan 9, 2007

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

Dec 11, 2004

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?

Dec 12, 2006

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

Jan 26, 2006

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

Jul 17, 2005

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

Jun 22, 2005

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'

Mar 10, 2007

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?

Jan 17, 2006

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

Jan 27, 2005

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

Jul 17, 2005

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

Jan 15, 2006

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

May 24, 2005

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

Mar 14, 2006

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

Jan 18, 2006

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

Jul 14, 2005

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

Aug 29, 2007

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

Nov 22, 2006

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

Oct 7, 2005

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

Aug 12, 2005

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

Aug 16, 2005

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

Mar 7, 2006

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

Nov 17, 2005

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

Dec 10, 2005

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

Nov 17, 2006

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

Feb 7, 2007

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

Nov 1, 2006

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?

Nov 2, 2005

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

View 14 Replies View Related

Numbers As Null

Jan 23, 2006

I want to retrieve a line of numbers from a table, ranging from 1 to 5. I've stored missing values as 8. I want to add them together using PHP, but treat 8 as missing/null, not as the number 8.

View 1 Replies View Related

Dealing With Null

Aug 30, 2007

select max(ID) + 1 from table1

Now my table contains no entry so i am not able to proceed; i tried using.

if(!resultSet)
then ID = 1.

View 6 Replies View Related

NULL Return 0.00

Mar 3, 2006

I have a php page that accept user input into a field (decimal value). I set the default value of the field as blank and accept null value. I insert a null value, it return 0.00. I want the field to return null value to me. What should I do for the field to return null value.

View 6 Replies View Related

Way To Insert NULL Into Db?

Sep 7, 2009

I have a script which needs users to fill out certain info and leave certain info blank. When they leave a certain field blank I need to add NULL into the db for that column. Below is my current way of doing it, but I bet there is a better way, what is a better way of what I am doing below, I am looking for something more secure if the user tries to play with it.PHP Code:

if(empty($_POST['keyword_two'])){
$keywordbase_one="`keyword_two`=NULL,";
}else{

[code]...

View 16 Replies View Related

Omit A Div If Its Null?

Apr 15, 2011

I have a div that looks like this:

<div id="restinfoinn">
<div id="resthead">Purpose</div>
<div id="restcontstitle2"><?php echo $row_pages_here['purpose']; ?></div>
</div>

I want it to be omitted if the value of purpose is empty/null. How can I do this?

View 2 Replies View Related

What Does This Mean - If (null === ($bar = $foo->getBar()))

May 8, 2011

When we have something like:

if (null === ($bar = $foo->getBar())) {
}

Are we doing three things on this single line ? Are we:

1) Declaring a variable.
2) Attribute that variable a value.
3) Check if that variable value is null.

View 3 Replies View Related

PHP Null Values

Jul 18, 2007

NULL is converted to blank in php array when i use mysql_fetch_array . I want something where NULL remains as it is in php array.

View 10 Replies View Related

HTTP_REFERER Is Null

Aug 13, 2007

I have a normal HTML link on an html page on one site pointing to a test.php file on another site.

I want to get the URL of the refering page using PHP, but have so far been unsuccessful.

Both $_SERVER['HTTP_REFERER'] and getenv('HTTP_REFERER') provide null results.

Also, phpinfo() does not display the HTTP_REFERER.

I can successfully get the remote IP addresses with $_SERVER['REMOTE_ADDR'].

JavaScript successfully displays the correct refering URL with:

<script language=javascript>document.write(referer);</script>

so, apparently, the header information is available.

I have tried this with MSIE and Firefox browsers.

I have also placed the test.php file on two different servers, but in each case PHP failed to find the refering URL.

View 3 Replies View Related

Array Is Null

Nov 12, 2007

I need to run a check to see if an array is null. Here is the section I am having problems with.

    $bowl_query=mysql_query($bowl_sql);
    while($bowl_array=mysql_fetch_array($bowl_query)){
        $amt=$bowl_array['subtrans_paid'];
if($bowl_array='NULL'){
$bowl_award="DUE";
}
if($amt > '3.00'){
$bowl_award="Yes";
}else{
$bowl_award="No";
}

View 2 Replies View Related

Get Rid Of Null Values

Sep 23, 2010

I have a php page where user/db info is being passed:

[code]...

As you can see, null values are being passed as well. I am hoping that someone can show me the correct way to use php unset to get rid of these null values.

View 2 Replies View Related

Setting New Object To Null?

Feb 17, 2006

How do you set an object to null?

$mail = new PHPMailer();
$mail = ?

View 2 Replies View Related

Preg_match - How To Match X00 (null)?

Jun 6, 2006

I'd like to work with a binary file....

I read the whole file into variable (it conatains binary data from 00-FF):

$fp=fopen($cfg,"r");
$content=fread($fp,filesize($cfg));
fclose($fp);

// and then I'd like to check if it contains special binary sequence, let's say bytes "00 01
02 03":

$replacestring="/x00x01x02x03/im";

if (preg_match($replacestring,$content)==0) {
echo("bad input file format");
exit();
}

but i get error message:

<b>Warning</b>: preg_match(): No ending delimiter '/' found in <b>test.bat</b> on
line <b>57</b><br />

I think it is maybe because php uses strings terminated with null, but can i force php to use strings with predefined length for example? Is there a way to work with strings containing null characters?

View 4 Replies View Related

NULL Expected, Won't Show Up ...

Mar 18, 2006

I have tho following code.

$_GET['artile'] looks like this: /2006/03/lorem_ipsum

$locationinfo = explode('/', trim( $_GET['article'] , '/') );

list( $article_year, $article_month, $article_url ) = $locationinfo;

echo '<br>year: '.(($article_year === NULL)? 'null': $article_year);
echo '<br>month: '.(($article_month === NULL)? 'null': $article_month);
echo '<br>article: '.(($article_url === NULL)? 'null': $article_url);

The weird thing is, if $_GET['article'] is empty, $article_year isn't
NULL, but the rest is. This doesn't make any sense to me ...

View 8 Replies View Related

Returning A Null Reference In PHP 4.4.2

Aug 3, 2006

Consider a class that encapsulates an associative array. It has two
"setter" methods:

class A
{
....
function setAttribute( $name, $value )
{
$this->attributes[ $name ] = $value;
}
....
function setAttributeByRef( $name, &$value )
{
$this->attributes[ $name ] =& $value;
}
....

The following "getter" method *used* to work just fine prior to version
4.4.2:

....
function & getAttribute( $name )
{
if ( isset( $this->attributes[ $name ] ) )
return $this->attributes[ $name ];
return NULL;
}
....

However, as of version 4.4.2, this throws a "FATAL: Only variable
references should be returned by reference." error. Unfortunately, my
host (and several of my client hosts) are stuck on this version.

Is there an elegant way to solve this problem? I want to return a value
indicating that no such attribute exists.

(I've googled the problem and can't find anything useful other than a
suggestion in a PHP bug report that I learn how to write "proper"
code.)

View 4 Replies View Related

ADVERTISEMENT