If(isset || empty)!
Hello,
I was hoping someone could give me the equivalent to PHPs
if(isset) and if(empty) operators. I checked Adobe's ActionScript
Dictionary and came up with nothing. Please help! I need an element
that can check to see if a field (text, date, etc...) is empty or
not.
Would greatly appreciate any input, this project is for work.
Thanks in advance,
Michael Loring
In ActionScript 3, you can test for null when it comes to any
object class. For Number, you can can use isNaN (is not-a-number);
Booleans can either be true or false. If you can have 'unset'
Boolean, it is false by default.
var amount:Number; // use isNaN(amount)
var name:String; // use name == null
var person:Person; // use person == null
Similar Messages
-
Need a site for how to redirect if session is empty
I have a session that i have created as soon as someone
logins. I need some
help on how to redirect the person if they try to access a
page without the
session.
i have 5 pages... based on your login you entered, i am
keeping that name in
the session... on each page i have a stored procedure that is
executed on
submit to verify that name against the table to add the recid
into the new
table..
I want to make sure that on page load if that session is
empty then redirect
to main page to login and continuethanks for the reply... cant tell you if it works, im working
on ASP that
was my fault for not stating it...
Building the app in ASP, SQL2005 using DW8
"geschenk" <[email protected]> wrote in
message
news:f0tasq$oho$[email protected]..
> You´ll probably just need to paste the following
snippet *at the very
> beginning*
(line 1) of the respective page:
>
> <?php
> if(!isset($_SESSION['username'])) { // if session
variable "username"
> doesn´t
> exist or has expired...
> header('Location: login.php'); // ...redirect to the
login page
> }
> ?>
>
> I *think* this should work
> -
PHP+MySQL query with empty value
Hi!
Software is DW8 with Apache 2.0.48, MySQL ver. 4.0.15a, PHP
4.2.3.
We had problem when a submitted value for 'regionID' in the
submit page
was left blank and the following error message appears in the
result page:
"You have an error in your SQL syntax. Check the manual that
corresponds
to your MySQL server version for the right syntax to use near
'LIMIT 0,
3' at line 1"
The problem was solved by adding at the top of the page:
<?php
if (isset($_POST['regionID']) &&
empty($_POST['regionID'])) {
$_POST['regionID'] = '0';
?>
How to change the above code to retrieve ALL records when an
empty \
blank value is submitted for 'regionID'?
TIA
Nanubbgirl wrote:
> Something I picked up at a PHP/MySQL seminar...
$_REQUEST works in place of
> either $_GET or $_POST. It basically means use either
get or post. But it is
> less precise because it can pick up either variable and
has to think about the
> request...
I'm afraid you've picked up rather poor information.
$_REQUEST relies on
register_globals being turned on. Since register_globals is
considered a
major security risk, the default setting has been off since
April 2002.
Many hosting companies have turned register_globals on, in
spite of the
security problems, because so many poorly written scripts
rely on it.
The PHP development team has decided to resolve this security
issue once
and for all by removing register_globals from PHP 6.
Forget $_REQUEST. Use $_POST and $_GET always. It's safer,
and it's
futureproof.
David Powers
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "Foundation PHP 5 for Flash" (friends of ED)
http://foundationphp.com/ -
Php emptying $_post
hello
i am having a play trying to create a simple shopping checkout, using code, no specialist software.
everything is working fine, except when i add or delete an item, and refresh the page, the add/delete is being repeated. which is obviousley bad.
i've tried unsetting the $_posts and emptying any variable being used, but this isn't doing the trick. any ideas....p.s, i'm trying to get the delete item code to work first, so have not altered my add item code.
to test the page, go to http://www.malcmabe.co.uk/custdetails.php
create a username and password using the top columns.click on search for items, and type 'nike' into the search box. click on one of the products and then add x amount to the basket.
if you then f5 refresh, the process is repeated.
in the item code column, type in the item code of the product you have chosen, and choose a quantity to delete. this will delete fine, but if you f5 refresh, another deletion takes place.
here is the code for deletion process:
if(isset($_POST['delitem']))
$code = $_POST['itemcode'];
$quant = $_POST['delquant'];
print("<br/> ".$code." ".$quant);
mysql_query("delete from checkout where itemid = '$code' and username = '$username' LIMIT $quant ");
unset($_POST['delitem']);
unset($_POST['itemcode']);
unset($_POST['delquant']);
$code = null;
$quant = null;
i would appreciate any help. thanksthanks david
but what i'm getting at, is that if the user adds or deletes an item, and then refreshes for whatever reason, than another item will be added or deleted.
basically, i want no post items to be sent when they refresh the page.
the only time i want data to be sent is when they press a button. -
I have a username field, and if the user changed their username already, change_uname will = 1. then, the text field for username will be disabled. here is my code:
<input type="text" name="uname" <?php if($change_uname == 1) { echo "disabled='disabled'"; } ?> value="<?php echo $uname; ?>">
and the php code:
if(isset($_POST['modify'])) {
$uname = $_POST['uname'];
echo "username: " . $_POST['uname'];
the only problem is, when change_uname = 1, it's not able to retreive the username...Hi,
The Empty Fields is used when a field is missing from the Source and all the values in the Source are Null.
When this field is required, then we do not need to add this field in the Source. Infact, we can do this in Import Manager also. Provided the only Value in this source field is NULL
1. Then You use this option of Empty Fields by Adding a Field in the Source hierarchy.
2. Map the Added field to the Destination
3. Map the Null Value to the Destination value.
For further understanding , Please refer page No- 90 & 228.
Hope it helps.
Thanks and Regards
Nitin Jain -
Advanced search for a price range while checking for an empty values using php in DW
I am creating an advanced search with DW php. I would like to submit a search where some entrys can be left black. So checking for empty values (which I have managed, thank you David Powel), however when searching between multiple price ranges does not seem to work.
please see attached forms:
The search page:
<form action="Detailed-Search-Result.php" method="get" target="_self"><table width="90%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td colspan="2"><label for="Detailed Search">Advanced Search</label></td>
</tr><tr>
<td><label for="Product">Product:</label>
</td>
<td><select name="Category" id="Category">
<option value=></option>
<option value="Keyboard">Keyboard</option>
<option value="Piano">Piano</option>
</select></td>
</tr>
<tr>
<td><label for="Make">Make:</label>
</td>
<td><select name="Manufacturer">
<option value=></option>
<option value="Boss">Boss</option>
<option value="Casio">Casio</option>
<option value="Kawai">Kawai</option>
<option value="Ketron">Ketron</option>
<option value="Korg">Korg</option>
<option value="Roland">Roland</option>
<option value="Samson">Samson</option>
<option value="Yamaha">Yamaha</option>
</select></td>
</tr>
<tr>
<td><label for="Color">Color:</label></td>
<td><select name="Color">
<option value=></option>
<option value="Black">Black</option>
<option value="Cherry">Cherry</option>
<option value="Mahogany">Mahogany</option>
<option value="Polished Eboney">Polished Eboney</option>
<option value="Rosewood">Rosewood</option>
<option value="White">White</option>
<option value="Red">Red</option>
</select></td>
</tr>
<tr>
<td><label for="Price">Price:</label></td>
<td><select name="Price">
<option value=></option>
<option value="0-500">£0-500</option>
<option value="500-1000">£500-1000</option>
<option value="1000-2000">£1000-2000</option>
<option value="2000">£2000></option>
</select></td>
</tr>
<tr>
<td colspan="2">
<input name="Search2" type="submit" id="Search2"></td>
</tr>
</table>
</form>
The results page
$varCategory_rsgetsearch2 = "%";
if (isset($_GET['Category'])) {
$varCategory_rsgetsearch2 = $_GET['Category'];
$varMake_rsgetsearch2 = "%";
if (isset($_GET['Manufacturer'])) {
$varMake_rsgetsearch2 = $_GET['Manufacturer'];
$varColor_rsgetsearch2 = "%";
if (isset($_GET['Color'])) {
$varColor_rsgetsearch2 = $_GET['Color'];
$varPrice_rsgetsearch2 = "%";
if (isset($_GET['Price'])) {
$varPrice_rsgetsearch2 = $_GET['Price'];
mysql_select_db($database_dBconn, $dBconn);
$query_rsgetsearch2 = 'SELECT * FROM products';
$where = false;
if (isset($_GET['Category']) && !empty($_GET['Category'])) {
$query_rsgetsearch2 .= ' WHERE Category LIKE varCategory '. GetSQLValueString($_GET['Category'], 'text');
$where = true;
if (isset($_GET['Manufacturer']) && !empty($_GET['Manufacturer'])) {
if ($where) {
$query_rsgetsearch2 .= ' AND ';
} else {
$query_rsgetsearch2 .= ' WHERE ';
$where = true;
$query_rsgetsearch2 .= 'Manufacturer LIKE varManufacturer ' . GetSQLValueString($_GET['Manufacturer'], 'text');
if (isset($_GET['Color']) && !empty($_GET['Color'])) {
if ($where) {
$query_rsgetsearch2 .= ' AND ';
} else {
$query_rsgetsearch2 .= ' WHERE ';
$where = true;
$query_rsgetsearch2 .= 'Color LIKE varColor ' . GetSQLValueString($_GET['Color'], 'text');
if (isset($_GET['Price']) && !empty($_GET['Price'])) {
if ($where) {
$query_rsgetsearch2 .= ' AND ';
} else {
$query_rsgetsearch2 .= ' WHERE ';
$where = true;
switch( $_GET['Price'] ){
case '0-500':
$query_rsgetsearch2 .= ' RRP BETWEEN 0 AND 500 ORDER BY price ASC'. GetSQLValueString($_GET['Price'], 'text');
break;
case '500-1000':
$query_rsgetsearch2 .= ' RRP BETWEEN 500 AND 1000 ORDER BY price ASC'. GetSQLValueString($_GET['Price'], 'text');
break;
case '1000-2000':
$query_rsgetsearch2 .= ' RRP BETWEEN 1000 AND 2000 ORDER BY price ASC'. GetSQLValueString($_GET['Price'], 'text');
break;
case '2000':
$query_rsgetsearch2 .= ' RRP BETWEEN 2000 AND 10000 ORDER BY price ASC'. GetSQLValueString($_GET['Price'], 'text');
break;
$query_rsgetsearch2 = sprintf("SELECT * FROM products WHERE Category LIKE %s AND products.Manufacturer LIKE %s AND products.Color LIKE %s", GetSQLValueString("%" . $varCategory_rsgetsearch2 . "%", "text"),GetSQLValueString("%" . $varMake_rsgetsearch2 . "%", "text"),GetSQLValueString("%" . $varColor_rsgetsearch2 . "%", "text"));
$query_limit_rsgetsearch2 = sprintf("%s LIMIT %d, %d", $query_rsgetsearch2, $startRow_rsgetsearch2, $maxRows_rsgetsearch2);
$rsgetsearch2 = mysql_query($query_limit_rsgetsearch2, $dBconn) or die(mysql_error());
$row_rsgetsearch2 = mysql_fetch_assoc($rsgetsearch2);
I would be greatfull for any helpI have managed to solve the problem.
In the end I didn't check if the values were empty, as it worked fine without. However the switch of the price didn't work in combination with the rest of the query.
I've solved the problem as follows:
$varCategory_rsgetsearch2 = "%";
if (isset($_GET['Category'])) {
$varCategory_rsgetsearch2 = $_GET['Category'];
$varMake_rsgetsearch2 = "%";
if (isset($_GET['Manufacturer'])) {
$varMake_rsgetsearch2 = $_GET['Manufacturer'];
$varColor_rsgetsearch2 = "%";
if (isset($_GET['Color'])) {
$varColor_rsgetsearch2 = $_GET['Color'];
$varPrice_rsgetsearch2 = "%";
if (isset($_GET['Keysound_price'])) {
$varPrice_rsgetsearch2 = $_GET['price'];
mysql_select_db($database_dBconn, $dBconn);
$query_rsgetsearch2 = sprintf("SELECT * FROM products WHERE Category LIKE %s AND products.Manufacturer LIKE %s AND products.Color LIKE %s", GetSQLValueString("%" . $varCategory_rsgetsearch2 . "%", "text"),GetSQLValueString("%" . $varMake_rsgetsearch2 . "%", "text"),GetSQLValueString("%" . $varColor_rsgetsearch2 . "%", "text") );
switch( $_GET['price'] ){
case '0-500':
$query_rsgetsearch2 .= ' AND price BETWEEN 0 AND 500 ORDER BY price ASC';
break;
case '500-1000':
$query_rsgetsearch2 .= ' AND price BETWEEN 500 AND 1000 ORDER BYprice ASC';
break;
case '1000-2000':
$query_rsgetsearch2 .= ' AND price BETWEEN 1000 AND 2000 ORDER BY price ASC';
break;
case '2000':
$query_rsgetsearch2 .= ' AND price BETWEEN 2000 AND 10000 ORDER BY price ASC';
break;
$query_limit_rsgetsearch2 = sprintf("%s LIMIT %d, %d", $query_rsgetsearch2, $startRow_rsgetsearch2, $maxRows_rsgetsearch2);
$rsgetsearch2 = mysql_query($query_limit_rsgetsearch2, $dBconn) or die(mysql_error());
$row_rsgetsearch2 = mysql_fetch_assoc($rsgetsearch2);
I'm sure that you can keep the checking for values in, however for me the was no need for it anymore.
Thanks for all your help -
I am trying to create a form that searches through a recordset. I am wondering, if several of the fields within the search form are left blank when submitted by the "GET" method, how I can have the query string ignore those empty parameters in the URL. I posted a similar question a little earlier and got no responses. I'm a newbie so let me now if I'm not phrasing my question correctly or something.
I've attempted to use the longer version of the code to make my select statement work. This is the code that I've got now:
$query_rs_results = "SELECT dogid, b_email, b_fname, b_lname, b_phone, b_url, dob, dod, reg_name, reg_no, o_email, o_fname, o_lname, o_phone, o_url, registry, semen_l, semen_f, semen_fc, semen_fr, photo FROM dog_main";
// Set a flag to indicate whether the query has a WHERE clause
// Set a variable to indicate if the select statement has a color value selected
$where = false;
$color = 0;
if (isset($_GET['arm']) && !empty($_GET['arm'])) {
$query_rs_results .= ' WHERE arm = '. GetSQLValueString($_GET['arm'], 'text');
$where = true;
if (isset($_GET['bite']) && !empty($_GET['bite'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'bite = ' . GetSQLValueString($_GET['bite'], 'text');
if (isset($_GET['body']) && !empty($_GET['body'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'body1 = ' . GetSQLValueString($_GET['body'], 'text');
if (isset($_GET['breadth']) && !empty($_GET['breadth'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'breadth = ' . GetSQLValueString($_GET['breadth'], 'text');
if (isset($_GET['brisket']) && !empty($_GET['brisket'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'brisket = ' . GetSQLValueString($_GET['brisket'], 'text');
if (isset($_GET['dentition']) && !empty($_GET['dentition'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'dentition = ' . GetSQLValueString($_GET['dentition'], 'text');
if (isset($_GET['color_b']) && !empty($_GET['color_b'])) {
$color = $color + 1;
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$query_rs_results .= '(color = ' . GetSQLValueString($_GET['color_b'], 'text');
if (isset($_GET['color_bl']) && !empty($_GET['color_bl'])) {
$color = $color + 1;
If ($color > 1) {
$query_rs_results .= ' OR ';
} else {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$query_rs_results .= 'color = ' . GetSQLValueString($_GET['color_bl'], 'text');
if (isset($_GET['color_br']) && !empty($_GET['color_br'])) {
$color = $color + 1;
If ($color > 1) {
$query_rs_results .= ' OR ';
} else {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$query_rs_results .= 'color = ' . GetSQLValueString($_GET['color_br'], 'text');
if (isset($_GET['color_f']) && !empty($_GET['color_f'])) {
$color = $color + 1;
If ($color > 1) {
$query_rs_results .= ' OR ';
} else {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$query_rs_results .= 'color = ' . GetSQLValueString($_GET['color_f'], 'text');
if (isset($_GET['color_h']) && !empty($_GET['color_h'])) {
$color = $color + 1;
If ($color > 1) {
$query_rs_results .= ' OR ';
} else {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$query_rs_results .= 'color = ' . GetSQLValueString($_GET['color_h'], 'text');
if (isset($_GET['color_m']) && !empty($_GET['color_m'])) {
$color = $color + 1;
If ($color > 1) {
$query_rs_results .= ' OR ';
} else {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$query_rs_results .= 'color = ' . GetSQLValueString($_GET['color_m'], 'text');
if (isset($_GET['color_o']) && !empty($_GET['color_o'])) {
$color = $color + 1;
If ($color > 1) {
$query_rs_results .= ' OR ';
} else {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$query_rs_results .= 'color = ' . GetSQLValueString($_GET['color_o'], 'text');
if ($color > 0) {
$query_rs_results .= ') ';
if (isset($_GET['ears']) && !empty($_GET['ears'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'ears = ' . GetSQLValueString($_GET['ears'], 'text');
if (isset($_GET['eye_color']) && !empty($_GET['eye_color'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'eye_color = ' . GetSQLValueString($_GET['eye_color'], 'text');
if (isset($_GET['eye_shape']) && !empty($_GET['eye_shape'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'eye_shape = ' . GetSQLValueString($_GET['eye_shape'], 'text');
if (isset($_GET['eye_tight']) && !empty($_GET['eye_tight'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'eye_tight = ' . GetSQLValueString($_GET['eye_tight'], 'text');
if (isset($_GET['f_feet']) && !empty($_GET['f_feet'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'f_feet = ' . GetSQLValueString($_GET['f_feet'], 'text');
if (isset($_GET['head']) && !empty($_GET['head'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'head = ' . GetSQLValueString($_GET['head'], 'text');
if (isset($_GET['hocks']) && !empty($_GET['hocks'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'hocks = ' . GetSQLValueString($_GET['hocks'], 'text');
if (isset($_GET['lip']) && !empty($_GET['lip'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'lip = ' . GetSQLValueString($_GET['lip'], 'text');
if (isset($_GET['longevity']) && !empty($_GET['longevity'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'longevity = ' . GetSQLValueString($_GET['longevity'], 'text');
if (isset($_GET['neck_length']) && !empty($_GET['neck_length'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'neck_length = ' . GetSQLValueString($_GET['neck_length'], 'text');
if (isset($_GET['neck_set']) && !empty($_GET['neck_set'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'neck_set = ' . GetSQLValueString($_GET['neck_set'], 'text');
if (isset($_GET['r_angulation']) && !empty($_GET['r_angulation'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'r_angulation = ' . GetSQLValueString($_GET['r_angulation'], 'text');
if (isset($_GET['r_feet']) && !empty($_GET['r_feet'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'r_feet = ' . GetSQLValueString($_GET['r_feet'], 'text');
if (isset($_GET['semen_f']) && !empty($_GET['semen_f'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'semen_f = ' . GetSQLValueString($_GET['semen_f'], 'text');
if (isset($_GET['semen_fc']) && !empty($_GET['semen_fc'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'semen_fc = ' . GetSQLValueString($_GET['semen_fc'], 'text');
if (isset($_GET['semen_fr']) && !empty($_GET['semen_fr'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'semen_fr = ' . GetSQLValueString($_GET['semen_fr'], 'text');
if (isset($_GET['semen_l']) && !empty($_GET['semen_l'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'semen_l = ' . GetSQLValueString($_GET['semen_l'], 'text');
if (isset($_GET['shoulders']) && !empty($_GET['shoulders'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'shoulders = ' . GetSQLValueString($_GET['shoulders'], 'text');
if (isset($_GET['tail_length']) && !empty($_GET['tail_length'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'tail_length = ' . GetSQLValueString($_GET['tail_length'], 'text');
if (isset($_GET['tail_set']) && !empty($_GET['tail_set'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'tail_set = ' . GetSQLValueString($_GET['tail_set'], 'text');
if (isset($_GET['temperament']) && !empty($_GET['temperament'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'temperament = ' . GetSQLValueString($_GET['temperament'], 'text');
if (isset($_GET['topline']) && !empty($_GET['topline'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'topline = ' . GetSQLValueString($_GET['topline'], 'text');
if (isset($_GET['withers']) && !empty($_GET['withers'])) {
if ($where) {
$query_rs_results .= ' AND ';
} else {
$query_rs_results .= ' WHERE ';
$where = true;
$query_rs_results .= 'withers = ' . GetSQLValueString($_GET['withers'], 'text');
echo "Query search = ".$query_rs_results;
$query_limit_rs_results = sprintf("%s LIMIT %d, %d", $query_rs_results, $startRow_rs_results, $maxRows_rs_results);
$rs_results = mysql_query($query_limit_rs_results, $dqdb) or die(mysql_error());
$row_rs_results = mysql_fetch_assoc($rs_results);
if (isset($_POST['totalRows_rs_results'])) {
$totalRows_rs_results = $_POST['totalRows_rs_results'];
} else {
$all_rs_results = mysql_query($query_rs_results);
$totalRows_rs_results = mysql_num_rows($all_rs_results);
$totalPages_rs_results = ceil($totalRows_rs_results/$maxRows_rs_results)-1;
I'm echoing $query_rs_results to verify that it is building the select statement correctly, but it is not. The select statement being echoed is:
SELECT dogid, b_email, b_fname, b_lname, b_phone, b_url, dob, dod, reg_name, reg_no, o_email, o_fname, o_lname, o_phone, o_url, registry, semen_l, semen_f, semen_fc, semen_fr, photo FROM dog_main
The results page is displaying every dog in the database.
What am I missing here?
TIA,
Laura -
Cannot assign an empty string to a parameter with JDBC type VARCHAR
Hi,
I am seeing the aforementioned error in the logs. I am guessing its happening whenever I am starting an agent instance in PCo. Can somebody explain whats going on?
Regards,
Chanti.
Heres the complete detail from logs -
Log Record Details
Message: Unable to retreive path for , com.sap.sql.log.OpenSQLException: Failed to set the parameter 1 of the statement >>SELECT ID, PARENTID, FULLPATH, CREATED, CREATEDBY, MODIFIED, MODIFIEDBY, REMOTEPATH, CHECKEDOUTBY FROM XMII_PATHS WHERE FULLPATH = ? <<: Cannot assign an empty string to a parameter with JDBC type >>VARCHAR<<.
Date: 2010-03-12
Time: 11:32:37:435
Category: com.sap.xmii.system.FileManager
Location: com.sap.xmii.system.FileManager
Application: sap.com/xappsxmiiearSounds like a UI browsing bug (when no path is selected from a catalog tree folder browser) - I would suggest logging a support ticket so that it can be addressed.
-
Oracle, Null and empty Strings
Currently I'm facing problems with a class, which contains a String, which
is set to "" (empty String).
When the class is persistent, oracle writes null to the table column
(which seems to be common oracle behaviour) and when retrieving the class,
the field is set to null as well, giving me a lot of null-pointer
exceptions.
Anyway ... I can cope with that (just a lot of extra work)
far worse is the problem, wenn searching objects, that have this field set
to "" oder null.
Oracle can't find the records because JDO creates Querys "where
string=null" or "where string=''" , where oracle expects "where string is
null" to find the records.
Is there a workaround or solution ?Yeah, that would work as well, thx, but since I have to cope with
null-Strings now everywhere in my program, it doesn't hurt just to forbid
empty strings on the program side.
In future times I'll test on Oracle first, then porting to DB/2 - this way
I suppose work is far less to garant compability.
Nevertheless ... having to set the bankcode into quotes is a kodo bug in
my opinion.
Kodo knows the type of classfields (in this case string) and shouldn't
send the parameter as a BigDecimal to the database.
Given that, and having only bankcodes of null (only neccesary when using
Oracle), the method would look like:
public Collection getAccounts (String bankCode)
throws Exception
return getAccounts (Account.class, "bankcode=="+bankcode);
which is how a transparent persistent layer, um, should be , um , I mean
... just transparent ;-D
Marc Prud'hommeaux wrote:
Stefan-
Couldn't you just do something like:
public Collection getAccounts (String bankCode)
throws Exception
String filter;
if (bankCode == null || bankCode.length () == 0)
filter = "(bankCode == null || bankCode == "")";
else
filter = "bankCode == "" + bankCode + """;
return getAccounts (Account.class, filter);
If I understand the problem correctly, this should work for all the
databases.
In article <[email protected]>, Stefan wrote:
What operations are you performing to cause this SQL to be issued? You
say you are having trouble removing objects, but this is clearly not a
DELETE statement. Is this the SQL that is issued when looking up
objects by identity?I'm not removing objects, I was removing just quotes from parameters ;-)
A string column... is it also represented as a string field in your class?Yeah ... just to give you an impression of the code:
First we have a class, representing a bank account:
public class Account {
private AccountMgr myAccountMgr;
private String bankCode;
private String id;
Note, that in nearly all cases bankCode will be a number or null.
I have a second class "AccountMgr", which does all of the persistant stuff
(seaching, making persistent etc.)
This class has two methods, one versatile (protected) to retrieve accounts
by a given filterString and one who just returns accounts by bankCode,
building the expected filterstring. Here is my current working version:
public class AccountMgr {
public Collection getAccounts(String bankCode) throws Exception {
if (bankCode!=null) {
if (bankCode.equals("")) {
throw new Exception("check code, bankCode='' not allowed to get
same behavior from DB2 and Oracle");
// if set, quote the bankCode
bankCode="""+bankCode+""";
return getAccounts(Account.class,"bankCode=="+bankCode);
protected Collection getAccounts(Class accountClass, String filterAdd)
throws Exception {
PersistenceManager pm = MyHelper.getPersistenceManager();
String filter="";
if (filterAdd!=null && !filterAdd.trim().equals("")) {
filter+=filterAdd + " && ";
filter += "myAccountMgr==_accMgr";
Query query = pm.newQuery(accountClass, filter);
query.declareParameters("AccountMgr _accMgr");
return (Collection) query.execute(this);
As you can see, in the first method I have to set the bankCode into
quotes, when it's not null.
This is because otherwise a filter like "bankCode=1234" will be translated
in a way, where 1234 is send as a BigDecimal to the database:
[...] executing statement <4239745>: (SELECT [...] FROM JDO_ACCOUNT t0
WHERE t0.BANKCODE = ? : [reused=1;params={(BigDecimal) 1234}]
Marc Prud'hommeaux [email protected]
SolarMetric Inc. http://www.solarmetric.com -
Hi There,
As far as I know, Null is not the same as an empty string; however, when I try this out, I get some unexpected results (well, at least unexpected for my liking):
SQL> CREATE TABLE TS (MID NUMBER,
2 MDESC VARCHAR2(20) DEFAULT '' NOT NULL);
Table created.
SQL> INSERT INTO TS VALUES(1,'');
INSERT INTO TS VALUES(1,'')
ERROR at line 1:
ORA-01400: cannot insert NULL into ("TT"."TS"."MDESC")So, according to the above scenario, I can't insert an empty string!! However, an empty string is a valid string that doesn't have tuples/data!!
How come Oracle translates the null string '' as NULL?
ThanksWilliam Robertson wrote:
There is a special case to do with CHAR values, whereby '' counts as a string and so gets blank-padded, whereas NULL does not.Are you referring to:
SQL> DECLARE
2 flag CHAR(2);
3 PROCEDURE check_null (p_flag IN CHAR)
4 IS
5 BEGIN
6 IF p_flag = ' '
7 THEN
8 dbms_output.put_line ('flag is equal to '' ''');
9 ELSIF p_flag IS NULL
10 THEN
11 dbms_output.put_line ('flag is null');
12 ELSE
13 dbms_output.put_line ('other');
14 END IF;
15 END;
16 BEGIN
17 flag := '';
18 check_null (flag);
19 flag := NULL;
20 check_null (flag);
21 end;
22 /
flag is equal to ' '
flag is null
PL/SQL procedure successfully completed.
SQL> alter session set events '10932 trace name context forever, level 16384';
Session altered.
SQL> DECLARE
2 flag CHAR(2);
3 PROCEDURE check_null (p_flag IN CHAR)
4 IS
5 BEGIN
6 IF p_flag = ' '
7 THEN
8 dbms_output.put_line ('flag is equal to '' ''');
9 ELSIF p_flag IS NULL
10 THEN
11 dbms_output.put_line ('flag is null');
12 ELSE
13 dbms_output.put_line ('other');
14 END IF;
15 END;
16 BEGIN
17 flag := '';
18 check_null (flag);
19 flag := NULL;
20 check_null (flag);
21 end;
22 /
flag is null
flag is null
PL/SQL procedure successfully completed.
SQL> SY.
P.S. Don't ask me why normal (or at least consistent) behavior is not the default. -
Null and empty string not being the same in object?
Hello,
I know that null and empty string are interpreted the same in oracle.
However I discovered the strange behaviour concerning user defined objects:
create or replace
TYPE object AS OBJECT (
value VARCHAR2(2000)
declare
xml xmltype;
obj object;
begin
obj := object('abcd');
xml := xmltype(obj);
dbms_output.put_line(xml.getStringVal());
obj.value := '';
xml := xmltype(obj);
dbms_output.put_line(xml.getStringVal());
obj.value := null;
xml := xmltype(obj);
dbms_output.put_line(xml.getStringVal());
end;
When creating xml from object, all not-null fields are transformed into xml tag.
I supposed that obj.value being either '' or null will lead to the same result.
However this is output from Oracle 9i:
<OBJECT_ID><VALUE>abcd</VALUE></OBJECT_ID>
<OBJECT_ID><VALUE></VALUE></OBJECT_ID>
<OBJECT_ID/>
Oracle 10g behaves as expected:
<OBJECT><VALUE>abcd</VALUE></OBJECT>
<OBJECT/>
<OBJECT/>
However Oracle 9i behaviour leads me to the conclusion that oracle
must somehow distinguish between empty string and null in user defined objects...
Can someone clarify this behaviour?
Thus is it possible to test if object's field is empty or null?However Oracle 9i behaviour leads me to the conclusion that oracle
must somehow distinguish between empty string and null in user defined objects...
Can someone clarify this behaviour?
Thus is it possible to test if object's field is empty or null?A lot of "fixes" were done, relating to XML in 10g and the XML functionality of 9i was known to be buggy.
I think you can safely assume that null and empty strings are treated the same by Oracle regardless. If you're using anything less than 10g, it's not supported any more anyway, so upgrade. Don't rely on any assumptions that may appear due to bugs. -
Difference in Null and Empty String
Hi,
I have been wondering about the difference between Null and Empty String in Java. So I wrote a small program like this:
public class CompareEmptyAndNullString {
public static void main(String args[]) {
String sNull = null;
String sEmpty = "";
try {
if (sNull.equalsIgnoreCase(sEmpty)) {
System.out.println("Null and Empty Strings are Equal");
} else {
System.out.println("Null and Empty Strings are Equal");
} catch (Exception e) {
e.printStackTrace();
This program throws Exception: java.lang.NullPointerException
at practice.programs.CompareEmptyAndNullString.main(CompareEmptyAndNullString.java:10)
Now if I change the IF Clause to if (sEmpty.equalsIgnoreCase(sNull)) then the Program outputs this: Null and Empty Strings are Equal
Can anyone explain why this would happen ?
Thanks in Advance !!JavaProwler wrote:
Saish,
Whether you do any of the following code, the JUnit Test always passes: I mean he NOT Sign doesnt make a difference ...
assert (! "".equals(null));
assert ("".equals(null));
You probably have assertions turned off. Note the the assert keyword has nothing to do with JUnit tests.
I think that older versions of JUnit, before assert was a language keyword (which started in 1.4 or 1.5), had a method called assert. Thus, if you have old-style JUnit tests, they might still compile, but the behavior is completely different from what it was in JUnit, and has nothing to do with JUnit at all.
If you turn assertions on (-ea flag in the JVM command line, I think), the second one will throw AssertionError. -
Check for null and empty - Arraylist
Hello all,
Can anyone tell me the best procedure to check for null and empty for an arraylist in a jsp using JSTL. I'm trying something like this;
<c:if test="${!empty sampleList}">
</c:if>
Help is greatly appreciated.
Thanks,
Greeshma...A null check might not be you best option. If your requirement is you must have both the date and time component supplied in order to populate EventDate, then I would use a Script Functoid that takes data and time as parameters.
In the C# method, first check if either is an empty string, if so return an empty string.
If not, TryParse the data, if successful, return a valid data string for EventDate. If not, error or return empty string, whichever satsifies the requirement. -
Interactive Report view is empty
Hi,
I'm on CRM 7.0 EHP3. I'm encountering empty report criteria and display when open the Campaign effectiveness and all other interactive report page. Please see the screen shot below. There is no error message on the screen, as well as ST22.
I've configured the interactive report and ran the configuration wizard /CRMBW/CONFIG_WIZARD successfully and no error found.
Also the roles SAP_CRM_OR_ADMIN, SAP_CRM_OR_CONFIG and SAP_CRM_OR_USER and SAP_ALL are given to the user in both clients.
Please let me know what could be the causes.
Thanks in advance.
cheers,
juliusOkay, problem seems solved. I don't know if it is a bug or a feature... (: Anyway, this view selects data from threads that had been created from a portal application. And if you create threads from WC_Collaboration server admin console, there's no data will be selected with FORUMCRAWLER_VW view. Sorry, have no time to check SQL query for those DB view, may be this behaviour is reasonable.
Edited by: Insomnium on 17.01.2013 2:33 -
Can I somehow print an empty report, and specify with a parameter how many times it should be repeated?
The report is a form with checkboxes, and sometimes we want the empty one for someone to fill in when out on the field. And since this form is a subreport, we cant print the entire report over again, but need the subreport to be repeated, let's say five times.
/Thank you!Please re-post if this is still an issue or purchase a case and have a dedicated support engineer work with you directly
Maybe you are looking for
-
Scanned document printing too small
Hi, I'm using Mac OS X 10.4, Epson 1660 Photo Scanner and Epson TWAIN (via Photoshop). I'm scanning a document for print, yet no matter what dpi I choose, the document prints out very small on my Canon i850 inkjet printer. I've wasted about 10 pages
-
Magic Moves not always Magic (non-linear slide orders)
Magic Moves opens the possibility of non-linear slide orders with animated transitions. Previously in keynote (KN '08), as far as I could ascertain, this was impossible. Now a slide with several hyper-linked objects can enjoy an animation of the on s
-
Hello all users of the sun forums. I've always been facinated of games and have been wrestling with the idea about learning enough to be able to make a simple online game. I got several questions, mainly to see if this is something realistic or if it
-
What does a file name like NYC14_(1008_of_88).cr2 mean?
NYC14 is my renaming convention. Naturally, it's followed by (1009 of 88) etc.
-
Iphoto crashes when editing photo
any suggestions?