Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Dont Want To Post Data If Row Field Is Empty


I dont want to post the $row ['thumbnail'] data in this string if the field is empty. Can someone help me out? ....




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Dont Want The File Names In The Browser Address Field
Is there a way in PHP where the file name do not appear in the browser address field.

eg. the url of a file is : http://www.somedomain.com/somepage.php.

but when a link to this page is clicked, only http://www.somedomain.com should show up in the browser address field.

Don't Show The Contents Of An Empty Field
I have a database which when queried brings back results one of which is an image name. The image name points to a subdirectory to display the image. Everything works fine but if there is no image name then the image is not found (obviously). How can I tell a result to not show the entry if it's empty?

The code goes something like this

mysql_select_db($databaseName,$db);

$result = mysql_query("SELECT * FROM reports WHERE target_page LIKE 'News' ORDER BY description",$db);

if ($myrow = mysql_fetch_array($result)) {

echo "
<table border=0 width=70%>n"; do { echo "
<tr>
n"; printf("
<td><B>%s</B></td>
</tr>n", $myrow["description"]); echo "
<tr>
n"; printf("
<td>%s</td>
</tr>n", $myrow["paragraph_1"]); echo "
<tr>
n"; printf("
<td>%s</td>
</tr>n", $myrow["paragraph_2"]); echo "
<tr>
n"; printf("
<td><IMG SRC=%s></td>
</tr>n", $myrow["image"]); echo "
n"; printf("

</tr>n", $myrow[""]); } while ($myrow = mysql_fetch_array($result)); echo "
</table>n"; } else { echo "Sorry, no records were found!"; } ?>

Any help would be appreciated

Empty Field Alert And Go Back
I would like to alert the user that leaves a blank field that it is obligatory. After that return him to the previous page... I tried this code but it doesn't work. I can either alert and continue to the next page, or simply return to the previous page without the alert.. Code:

Enter NULL If Field Is Empty
I have a script where I add news to a database. I am adding a new field for an image for the respective article, but I need the script to check if there is a value for the image or not, and if there isn't, I want it to enter NULL in the DB. Code:

Select Only Rows Where Certain Field Is Empty
Basically i need to select the rows from a table where the user is "$curr_user" and the "seen" field is empty. Then i want to count the rows and use the count in a javascript alert. Heres what i got so far: Code:

Empty Variables And 4.21 (POST/GET)
With global variables set to on, I always had the following in my script to make sure variables had a default value:

if (empty($var)) {
$var = 1;}

Now with 4.21, I changed it to:

if (empty($_GET['var'])) {
$var = 1;}

The problem is sometimes I use GET and sometimes I use POST. With global variables on it didn't matter. Now it does. Is there a way to do this? When I try if (empty($_GET['var']) || empty($_POST['var'])), it doesn't work because one or the other will always be empty at any one time.

From POST To GET: $_FILES Empty
I'm passing the code from $_POST to $_GET.

I've a page upload using $_FILES. when the page was in $_POST, it worked
fine, but now, in $_GET, the $_FILES is empty.

Empty Search Field Produces All Items In DB
I have a search on my site. It searches products in a catalog database. If you hit submit without anything in the search filed it comes back with all products in my catalog. Is there a way to stop this with a IF statement or something else. PHP Code:

Hiding An Empty Dynamic Image Field
How do you hide a empty dynamic image field on a page. This will mean that page will display images that have been uploaded and the empty image field will not appear if the user does'nt upload an image. I need some sort of if statement that says if the rsNews['newsImage'] does not contain an image, then show nothing on the page. But if the user uploads an image, show it. Code:

Query About Empty POST Arrays
I started programming in PHP recently and have a query about empty
$_POST arrays. I can see two scenarios when this could happen.

1. When some tries to directly load the page to which data is being
posted (for example, opening www.foo.com/xyz.php directly when a form
action is xyz.php)
2. When the user clicks the submit button without entering anything.

I am aware that Javascript validation can take care of the second case,
but it's unreliable. What is the accepted way of handling the above
situations on the server side?
Do I just reload the calling page if the array is empty?

Empty Texarea In Search Field Prints ALL Entries
I've got a search engine that works fine, except that if you click go without typing anything, It prints out all entries in the ddatabase, instead of just the relevant ones.
PHP Code:

An Extra Last Empty Field In An 'mysql_fetch_array' Result Array?
I seem to get an extra empty field in every 'mysql_fetch_array' command I issue. For example:

I have a simple table 'tblName':

ID Name
1 Jane
2 Joe
2 Doe

The following code:

$oCursor = mysql_query("SELECT ID from tblName WHERE Name='Jane'");
if (!$oCursor)
{
$bGo = false;
}
else
{
$aRow = mysql_fetch_array($oCursor);
}

results in:

count($aRow) = 2;

$aRow[0] = 1;
$aRow[1] = ''

Am I missing something, doing something wrong, a wrong PHP setting?

Disable Submit Button If Text Field Is Empty
I am unsure if this must be done with Ajax, or if it can be done with PHP. I have a simple search page where I want the submit button to be disabled if there is nothing entered in the text field, and once something IS entered, then the search button is enabled.

I was thinking Ajax, because I am looking for it to be real time and I am not sure if its possible with PHP as I am just a novice when it comes to certain things. So the button is always disabled when there is nothing, and enabled when the user enters something.

And lets say the user enters something and removes it, then the button disables again? Is this possible to do with PHP and if so, could someone please help me tackle this . Code:

Update Statement Causes Mysql Varchar Field To Be Set To Empty String
I have come across a problem that has me baffled.

I am using PHP with MySQL 4.1.14. Whenever I execute an update
statement against a specific table, some of the varchar fields do not
get set to the new values, but get set to empty strings instead.

I have simplified the code down to updating a single column in the
table, but the same results happen when updating just the single
column.

Here is the stripped down code which causes the problem:

$queryString = "UPDATE REGISTRATION SET passwd = '$pass'' WHERE id =
388";
$db = mysql_connect("hostname", "user", "pass");
mysql_select_db("CUSTOMER", $db) or die(mysql_error());
mysql_query($queryString, $db) or die(mysql_error());

Printing the query string after executing mysql_query shows the
following query:

UPDATE REGISTRATION SET passwd = 'test' WHERE id = 388

This query updates the column successfully when run directly through
phpMyAdmin. When run through PHP using the code above then column is
set to an empty string value.

There is no error returned if I call mysql_error() nor is there any
unusual info returned from mysql_info() (other than it telling me that
1 row was affected).

Does anyone have any ideas what the underlying problem is on this one?
Could be an attribute of the database table or columns that would cause
this behavior? I have racked my brain for a while over this problem.

Cannot Read Information From Form Using POST Or GET ($_Post Is Empty)
I am having problems in my php code. I am relatively new to php but I
know some basics.

This is the problem:

when i try to echo some information that is typed into form back to
the screen i get absolutely nothing. It seems like $_POST['name'] is
an empty string, along with $_POST and $_GET['name'].

I looked around to see if someone else had the same problem and found
that some people's code didn't work because of IE6. but i also tried
mine on Netscape and i got the same problem.

So why is $_POST empty after posting information. Even $_GET was
empty.

all of those returned empty

echo $_POST;
echo $_POST['name'];
echo $_GET['name'];

here is the code:
the code was originially meant to send an email but i commented the if
statement out to see why it wasn't working

<html>
<head><title>Feedback</title></head>
<body>

<?php

// Handle POST method.
//if ($_POST)
//{

$name = $_POST['name'];
$email = $_POST['email'];
$comments = $_POST['comments'];

// Compose simple text message:
$message = "Message from $name
($email)

Comments:

$comments";

// Send message to bob@microsoft.com
mail("email@email.com", "Feedback", $message);


Simulate Send Data With POST And Get Data From A Web Page (whith A Session)
I'd like to get text of a webpageB that I reach by putting
a login and a password in a webpageA.

I mean:
I'd like to get text of a WebPageB with a php script.
But before I can see WebPageB I have to autenticate myself
in a WebPageA writing my login and my password in a form,
the host recognise me and (by session) let me see the WebPageB.

The question is:
1)how to simulate send data (login an password) in form with a PHP script?
2)how to navigate in a Web usin the same session?

Post Two Values Into One Mysql Field?
I'm posting data into a MYSQL database, which works fine using the schema below and the php form below:

cms_test
story_id (int 3)
web_date (date)
web_time (time)

Code:

Post And Redirect With Post Data
The solution we have though up is the following:

1. The user fills in data in a form and hits submit
- This submits (POST) to another page (redirect.php)
2. redirect.php adds more POST data to POST and then submits all this POST data to another page (offsite [payment portal])

The reason why we have to do this is for someone who knows our to read html source code, could easily find the sucessful page which will then do the processing we need to do on our side. Which means freebeis.

Inserting Empty Data Into Mysql
I am creating an interface for my wife to keep track of what cross stitch threads she has. I have created a text area so she can enter a bunch at a time. I am trying to get the script to skip over blank lines. Code:

Creating Empty Variables For Input Data
I am creating a script that will be taking data from a POST and submitting
the data to variables which are placed within a hash for string to data
association. Then, using HTML::Table and Mail::Sendmail, the data is parsed
into an html table and then an email is created and send to a recipient.
So, my question is this; How do I take the input from a post form and have
the variables pick up the data and process it into a hash?

my $name = ;
my $instock = ;
my describe = ;
# Hash to hold inventory data
my %table_data = (
model ='$modelnumber',
item ='$name',
available ='$instock',
description ='$describe',
);

This is all the code I have written thus far, any pointers or suggestions
for this project?

Quickly Adding Text To A Mysql Text Field That Is NOT Empty
Is there a way to insert text into a mysql text field that already has
text into it; without having first to extract the existing data and
append the new text to that string variable and then insert the new
string.

Basically i'm looking for a way to do it with a single query not 2 (one
being a select to gather existing data).

Mysql Field. "" Or Empty?
how would i check if a mysql field is empty.

is it better to use ""

or is there some special function that checks if the field is empty?

Post Data To A CGI
How in PHP do you send post data to a CGI and let the CGI carry on the request (what I'm doing is: a form is filled out a load of PHP to check that each option is correct and some other stuff then when its ready redirects off to a CGI but sending the form data with it (using a post rather than a get).

Is It Possible To Post Data Through Url?
Is it possible to post a value to a database through a url? Something like PHP Code:

Raw POST Data
Is there a way to access the raw data sent to a PHP app via POST? I'm
trying to read the XML sent by a Flash program with XML.send() and its sent
via POST but not URL encoded. PHP is expecting URL encoding so it comes in
like:

$_POST['<?xml version'] = '"1.0"?>'

Perl can read it just fine like so:

read (STDIN, $rawpost, $ENV{'CONTENT_LENGTH'});
s/&amp;/&/g;

POST Data
I am trying to build a checkout process for my site that goes from filling in ship and bill info to confirm order info. The problem I am having is that I want to be able to skip the first step if the client already has an account and has signed in. This would be easy except I am posting the data from step1 (ship/bill info) on my form like:

<form action="<?php echo $_SERVER['PHP_SELF']; ?>?step=2" method="post" name="frmCheckout" id="frmCheckout" onSubmit="return checkShippingAndPaymentInfo();">

the onSubmit goes to a js function that will send the user back to step1 if data is missing.

in my confirm.php I check to see if the steps are being served up correct like
<?php 
if (!defined('WEB_ROOT')
    || !isset($_GET['step']) || (int)$_GET['step'] != 2
|| $_SERVER['HTTP_REFERER'] != 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?step=1') {
exit;
}

which works well for making sure that the user who is not logged in gives me all the required data - but also prohibits me from skipping step 1

I do set a session variable for ClientId - once logged in - so is there any way that I could add that to the condition so that I could skip step 1 ?? and how should I deal with the POST data normally retrieved from step1??

Post Data
im writing a small forum here, i have used a get to grab the button input to post a message, then it goes to a screen to post the data into mysql but im not sure the best way to deal with the post data once submitted: Code:

How Do I Get Image Data Into A Blob Field
I am trying to get image data into a mysql field (like a simple jpg). Does anyone have a quick tips on how to submit an image (through an html form) process via php and insert into a mysql blob field?

Pulling Data From The Last Field Of A Table
What is the command to view the last result in a table using a DB query?

Table Example
TABLE PEOPLE
>ID
>NAME
>POINTS

one thing, it cant be ORDER BY id DESC

If at all possible it has to be
SELECT * FROM people WHERE name=jon && id=**last id**

**last id** = Last id where the name jon was found.

Reverse Sending Data From Value Field
What I want is this. I have a page where I want to update information.
So lets say it is already:

Title - Milk
Category - Dairy
postDate - 9/18/2007

And I want to Change it to:
Title - Cheese
Category - Dairy
postDate - 9/18/2007


I want this page to display the information (before it is updated) in the edit field.

So right now I have this
<input name=title value="<?PHP echo $rows['deal_title'];?>"/>

What I am doing here, with the sql information excluded of course, is pull out the title of a row that was selected.

the information comes out but not well. One of the many input type "text" boxes are for inputting html links such as http://www.domain.com/ and the title would be used with html code as well (for visual formatting on the web page).

What ends up happening is when the information is first pulled from the database to fill in the values, after certain html characters (like > after <font...) the rest of information spills out of the text box and becomes uneditable because of this. Most of the code is also gone even though it is in the database.

Making A New EXIF Data Field...
Is there anyway with PHP to make a new EXIF data field in a JPG, like, for example, "Album"?

Ftp_nlist Returns False For Empty Directory Instead Of Empty Array
In an application installed with PHP5 it looks like ftp_nlist() returns
false if the directory is empty, instead of an empty array as it should
according to the manual. On the original server with PHP4 it works as
expected.

Is this a bug, or an undocumented change in PHP5, or a setting that
could be changed somewhere?

Post Data W/out Form
I want to post variables to a php script, but I do not want to use a form to do this... is there some sort of header I can use to redirect and post values to another page?

Cookies and sessions are not an option, URL line ('get') variables can't hold large enough a string...

Read Raw Post-Data In PHP
I need to read the RAW DATA that is sent using a HTTP-Post Command in PHP.

I cannot User $HTTP_POST_VARS since the Data is not associated with a particular variable.

Redirect With Post Data Using PHP
Normally I use javascript for doing this form1.submit() it works
properly. it can redirect to another page with post data. But there
is another problem. Some cheater Do Cheat with me. they click Stop
Button on IE when it is submitted and they view the source. by this
way they know my secure information what i need to supply to another
page..

Any One know this solution using PHP? I know there is a solution for doing this Because some websites use php to do it like 2CheckOut and WorldPay. But I don`t know what the solution. Can Anybody Help me?

Can't Get Data To Post To Mysql
What am I doing wrong with this code? I cant get my field values to post to my database....

Disregarding POST Data After It Is Used Once
I have written a pretty nice messageboard website in PHP, but it has one problem -- when a user posts a comment, it takes them back to the thread they were in and shows them the comment they just posted. However, if the user then hits their browser's "Refresh" or "Reload" button, the browser resends all the data that was in the comment form to the PHP script again, and reposts the data a second time.

Is there some way I can make this POST data disappear after it has been inserted into the MySQL database once? Or, perhaps a different solution would be to make a very small PHP script that only does one thing -- it takes in the comment data, inserts it into the database, then immediately forwards the user to the PHP script that actually draws the page... this way if the user hit the refresh button, it wouldn't be refreshing the page that the POST data was sent to.

CGI (in PHP) Can't Read POST Data
I am trying to have a CGI script write text to a file based on input
from a form. However my write.cgi's $_POST is empty. Whenever I use
write.php for the action of the form $_POST has the correct data.

The form uses POST method. I want to use write.cgi because only cgi
scripts can write to files in my server (run by suexec)

I have been researching this for two days now

Passing POST Data To Php-cgi.exe
How do I pass POST data to php-cgi.exe so that in the PHP script I can
work with that data using $_POST["variable"]?

Http POST Data
and I've been looking all day on the web for
an answer to this question.

I'm trying to send some binary data, a relatively large amount (~128K), to a
PHP script from a wireless device that has TCP/IP sockets. So I'm sending
all of my data manually (ie ,"POST http://www.blah.com/process.php
HTTP/1.0
").

I am able to send regular form data such as
"tireqty=3&oilqty=4&sparkqty=1&address=4204MainStreet

";
To do this I have a header for the content type like so: "Content-Type:
application/x-www-form-urlencoded
";"

I have even encoded my data in base64 so that it is ready to send as ASCII.
This data is broken into chunks where after each 76 characters there is a

line break. I read that I needed to do that.

But HOW do I send it? If I send it as form data, with variables, then it
only receives the data up until the first line break. I tried changing the
content type to "Content-Type: application/octet-stream
", thinking that I
could just send the data without form variables, but then how do you access
that from PHP? For example I tried sending the string "data=XXXYYY" where
XXXYYY is my base64 encoded data, but it didn't work.

I can't seem to find any good documentation about this. Which Content-Type
shouldI be using? Can I use octet-streams and still have the data connected
to php variables? It's very confusing.

Form Data Will Not Post
can anyone be so kind as to look at

http://www.mysolution.ws/HYPOCRITE.php

and let me know why it isn't passing the form data to

http://www.mysolution.ws/insertHYPOCRITES.php

for the most part, the scripts were created with
http://phpcodegenie.sourceforge.net/

How To Return Data Using POST
I have a vendor sending me a text file using POST. I have a PHP program
receiving the data that works. I need to in the same stream return an answer
via POST. How do I send that POST in the same stream?

A snip from the code for the output portion:

$LINKOUT = implode('', file($LINKFILE . '.out'));

$LOUT = array(
'http'=>array(
'method'=>"POST",
'header'=>"Content-type: application/x-www-form-urlencoded
" .
"Content-length: " . strlen("$LINKOUT"),
'content'=>"$LINKOUT"
)
);
$context = stream_context_create($LOUT);

Faking Post Data
i've copied my bank's login form and saved a copy on my computer.
However when i try to submit it, i get a 405 method not allowed error.
Can't for the life of me figure out why, it's posting exactly the same
data from exactly the same html code. Any ideas? It's a https (SSL)
site.

Problem With POST Data
I have a script that will upload a file and store its information in a database based on POST data. The script will set a variable to either a success message or an error message, depending on whether the upload was successful or not. The message variable will then be outputted to the user.

The problem here is that if a user successfully uploads a file and then clicks back or refresh in the browser, the "You are trying to view a page that contains POSTDATA" dialog will appear. If the user simply clicks OK on this dialog, the file will be re-uploaded and a duplicate of the submission's record will be created.

The only way I know to avoid this dialog is by using the header() function to clear the POST data. However, if I use this function, not only will the POST data be cleared, but the variable containing the success message will also be cleared, and there will be no confirmation to the user that their submission was uploaded successfully.

Resending Post Data?
I have a page that loads a calendar via POST (It can't be done with GET so don't suggest that)after you update some bookings it processes via POST and I want to return it back to the calendar page, but the page is set to purposely not load if it doesn't know what Year, Month, and the Location it needs to be querying for.  How can I reset this data, I thought of sending the user back in the browser, but I don't know how that would work as I can't envoke php going backwards.

POST Data In A Link..
Is it possible to to send POST data if you click a link? Such as, using a link to replace a submit button. A submit button usually has a value. (value=""). Could you do this in a link?

Refreshing & Post Data
Is there a good way to avoid the warning message that comes up when refreshing a page with post data? I've hard approaches here you use PHP to store the post data in GET variables and reload the page to itself, parse the form and proceed as normal, unsetting the GET variables before rendering the page. I guess this might work but probably not with files. Is there a more elegant solution?

AJAX & Post Data
Two part question:

#1. I've built a little AJAX app, but the problem is anytime I do an update, I have to delete my temp files before I can see the update. Is there anyway around this?

#2. Is there a way to know all the variables submitted to a form without knowing what the variables are before hand? For example, I have a form, where there are checkboxes. Each checkbox's name is an ID value from the database. When I submit the form, I need to know all the rows that were checked...

How To Clear POST Data?
I've looked everywhere and cannot find my answer. After a successful form submission it tells the admin it was successful but then I want the form to clear out. Because I do have it where the data is redisplayed in the form just in case of an error. But when there isn't an error and the form is processed it still shows the POST data ... anyway to clear this out?


Copyright © 2005-08 www.BigResource.com, All rights reserved