RE: [PHP-DB] undefined index

2001-05-01 Thread Henning Kilset Pedersen

Hi!

Drop the quotes around your array keys. It should be $row[imageurl] for
example.



--
Henning Kilset Pedersen
Anarchy Online Server Operations
Oracle, PHP, e-Commerce etc.
Funcom Oslo AS
-Original Message-
From: Petra [mailto:[EMAIL PROTECTED]]
Sent: 1. mai 2001 03:29
To: [EMAIL PROTECTED]
Subject: [PHP-DB] undefined index



hi to all

I try to get data listed out of my database with the statement

...
while ($row = mysql_fetch_array($sql)) {

$image = $row["imageurl"];
$id = $row["productID"];
$name = $row["cdescription"];
...

If i havent got anything in that field in my database I get the error
message in my browser

Undefined index: imageurl in ...

How can I overcome that problem? Is there a way to define a index if that
occurs and make it to not produce that error message?

Hope I have explained it understandable enough. If you need to know more
details let me know, I would appreciate any help I could get. Thanx

P.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] undefined index

2001-05-01 Thread Joe Brown

I don't think dropping the quotes is the best solution.

One might consider dropping the warning level in php.ini, if it is a
problem, or use numbered array like mysql_fetch_row() returns.

-Joe

""Henning Kilset Pedersen"" <[EMAIL PROTECTED]> wrote in message
000f01c0d251$59b79000$a26547c1@pedershk">news:000f01c0d251$59b79000$a26547c1@pedershk...
> Hi!
>
> Drop the quotes around your array keys. It should be $row[imageurl] for
> example.
>
>
>
> --
> Henning Kilset Pedersen
> Anarchy Online Server Operations
> Oracle, PHP, e-Commerce etc.
> Funcom Oslo AS
> -Original Message-
> From: Petra [mailto:[EMAIL PROTECTED]]
> Sent: 1. mai 2001 03:29
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] undefined index
>
>
>
> hi to all
>
> I try to get data listed out of my database with the statement
>
> ...
> while ($row = mysql_fetch_array($sql)) {
>
> $image = $row["imageurl"];
> $id = $row["productID"];
> $name = $row["cdescription"];
> ...
>
> If i havent got anything in that field in my database I get the error
> message in my browser
>
> Undefined index: imageurl in ...
>
> How can I overcome that problem? Is there a way to define a index if that
> occurs and make it to not produce that error message?
>
> Hope I have explained it understandable enough. If you need to know more
> details let me know, I would appreciate any help I could get. Thanx
>
> P.
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] undefined index

2001-05-01 Thread Phil Driscoll

Your best bet is to do some isset() calls:

eg

if(isset($row['imageurl']))
{
 $image=$row['imageurl'];
}
else
{
 /*maybe report the problems or handle it like this...*/
 $image=$default_image_url;
 /*where you have already set up $default_image_url to point somewhere
sensible*/
}

Cheers

--
Phil Driscoll
Dial Solutions
+44 (0)113 294 5112
http://www.dialsolutions.com
http://www.dtonline.org


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Undefined index and variables

2003-01-15 Thread Hutchins, Richard
It does not appear that you have posted the code from the add.php page in
your original post (below). From the error messages you provided, that seems
to be where the error is happening. You'll need to post the add.php code and
identify line #23 for us to be able to help.

> -Original Message-
> From: Fred Wright [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 15, 2003 6:57 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Undefined index and variables
> 
> 
> Hi to all
> Being new to PHP I am naturally experiencing some minor problems.
> 
> I have a form which processes Ref and Chassis data, when I 
> load Add.php
> which does work but on loading get errors
> 
> Notice: Undefined index: Ref in C:\Xitami\webpages\add.php on line 22
> Notice: Undefined index: Chassis in 
> C:\Xitami\webpages\add.php on line 23
> How do I get rid of these undefined errors? Could anyone 
> advise please.
> Regards
> Fred
> 
> printf("");
> 
> printf("");
> 
> printf("Reference:");
> 
> printf("");
> 
> printf("Chassis:");
> printf("");
> 
> printf("");
> 
> printf("");
> 
> printf("" );
> 
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] Undefined Index error when trying to insert data from a form into a db

2003-06-26 Thread Hutchins, Richard
Chris,

It appears that the indices called out in the lines of error code are not
being transferred from the Insert_Table_Form.html page and that is causing
the query to ultimately fail. Almost self-explanatory due to PHP's good
error reporting.

First make certain that the names of the form controls on the
INsert_Table_Form.html page match up exactly with the names in your code on
lines 9 through 21.

Secondly, make sure each of the controls has a value when you attempt to
post the data from Insert_Table_Form.html. Some form controls will not
appear in the $_POST['indices'] array if they do not contain a value and
when you try to reference those empty controls, they cause problems because
they were never posted.

Hope this helps.

Rich

> -Original Message-
> From: Christopher McCourt [mailto:[EMAIL PROTECTED]
> Sent: Thursday, June 26, 2003 12:54 PM
> To: PHP Lists
> Subject: [PHP-DB] Undefined Index error when trying to insert 
> data from
> a form into a db
> 
> 
> Hello to all:
>  
> I am getting the following error message when trying to 
> insert data from
> an html form into a MYSQL database that I recently created.  
> Can someone
> take a look at the errors and corresponding code and suggest some
> alternatives?
>  
> Thank you very much in advance for your assistance.
>  
> Regards,
> Chris McCourt
> ++
> ++
> 
>  
> Error Message:
>  
> Notice: Undefined index: Store_ID in c:\program files\apache
> group\apache\htdocs\insertdata.php on line 9
> 
> Notice: Undefined index: Postal_Code in c:\program files\apache
> group\apache\htdocs\insertdata.php on line 14
> 
> Notice: Undefined index: Cert_Org in c:\program files\apache
> group\apache\htdocs\insertdata.php on line 17
> 
> Notice: Undefined index: Cert_Level_ID in c:\program files\apache
> group\apache\htdocs\insertdata.php on line 18
> 
> Notice: Undefined index: Cert_Date in c:\program files\apache
> group\apache\htdocs\insertdata.php on line 19
> 
> Notice: Undefined index: Emerg_Contact_Name in c:\program files\apache
> group\apache\htdocs\insertdata.php on line 20
> 
> Notice: Undefined index: Emerg_Contact_Phone in c:\program 
> files\apache
> group\apache\htdocs\insertdata.php on line 21
> Error: Unable to execute insertion query.
>  
> +++
>  
> Original PHP Code:
>  
> 
> 
>  Inserting Data Into a Database
> 
>  /* This page receives and handles the data generated
> by the form "Insert_Table_Form.html"*/
>  
> $Store = ($_POST['Store_ID']);
> $Users = ($_POST['User_Name']);
> $Pass  = ($_POST['Password']);
> $Addr  = ($_POST['Address']);
> $State = ($_POST['State']);
> $Post  = ($_POST['Postal_Code']);
> $Phone = ($_POST['Phone']);
> $Email = ($_POST['EMail']);
> $Certor = ($_POST['Cert_Org']);
> $Certl = ($_POST['Cert_Level_ID']);
> $Certd = ($_POST['Cert_Date']);
> $Emergn = ($_POST['Emerg_Contact_Name']);
> $Emergp = ($_POST['Emerg_Contact_Phone']);
>  
>  
> //Set the variables for the database access:
> $Host = "localhost";
> $User = "root";
> $Password = "";
>  
> $Link = mysql_connect($Host, $User, $Password)
> or die("Could not connect: " . mysql_error());
> mysql_select_db('dive_store') or die("could not select database");
> $sql = mysql_query("INSERT INTO test_scores VALUES (NULL,
> '$Store', '$Users', '$Pass', '$Addr', '$State', '$Post',
> '$Phone', '$Email', '$Certor', '$Certd', '$Certl', 
> '$Emergn', '$Emergp')")
>  or die('Error: Unable to execute insertion query.'); 
>  
> $Result = mysql_query($sql)or die(mysql_error());
> if ($Result){
>   echo("Table Created successfully");
>   }else{
>   echo("error when creating table");
> }
> mysql_close($Link);
> ?>
> 
> 
> 
>  
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Undefined Index error when trying to insert data from a form into a db

2003-06-26 Thread Miles Thompson
1. Check the manual on use of $_POST and notch down your error reporting 
level. As these vars have not been defined PHP is throwing an error.

2. While you are at it, and  assuming that your variables are all received 
correctly, why not simplify your sql?

insert into test_scores set field_one = '$field_one', field_two = 
''$field_two ... and so forth. It makes debugging INFINITELY easier and 
gives you more control.

3. Not related to your question at all, what's the type of your first 
field? Does it allow NULL's? If so then default it to NULL. (Something 
tugging at the back of my mind says that a NULL should not be assignable, 
but that's another issue.)

HTH - Mlies Thompson

At 12:53 PM 6/26/2003 -0400, Christopher McCourt wrote:
Hello to all:

I am getting the following error message when trying to insert data from
an html form into a MYSQL database that I recently created.  Can someone
take a look at the errors and corresponding code and suggest some
alternatives?
Thank you very much in advance for your assistance.

Regards,
Chris McCourt


Error Message:

Notice: Undefined index: Store_ID in c:\program files\apache
group\apache\htdocs\insertdata.php on line 9
Notice: Undefined index: Postal_Code in c:\program files\apache
group\apache\htdocs\insertdata.php on line 14
Notice: Undefined index: Cert_Org in c:\program files\apache
group\apache\htdocs\insertdata.php on line 17
Notice: Undefined index: Cert_Level_ID in c:\program files\apache
group\apache\htdocs\insertdata.php on line 18
Notice: Undefined index: Cert_Date in c:\program files\apache
group\apache\htdocs\insertdata.php on line 19
Notice: Undefined index: Emerg_Contact_Name in c:\program files\apache
group\apache\htdocs\insertdata.php on line 20
Notice: Undefined index: Emerg_Contact_Phone in c:\program files\apache
group\apache\htdocs\insertdata.php on line 21
Error: Unable to execute insertion query.
+++

Original PHP Code:





--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php