logo-dw

Go Back   Dreamweaver Club Forums > Dreamweaver forums > Video Tutorials
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 02-19-2009, 08:14 PM   #1
inflict
 
Join Date: Feb 2009
Posts: 3
Default Creating Dynamic Dropdowns Tut Error

Having a problem with the selecting the make. I think it has to do with my java code but can't figure it out. The error shows:
Notice: Undefined index: make in C:\Documents and Settings\ryan\My Documents\Web Root\Test\dropdown.php on line 4

The make selection won't stay selected but the model section changes when you select the make. Anyone catch what I have wrong?

Code:

PHP Code:
<?php
require_once("Connections/connection.php");
 
$make    =    $_POST['make'];
 
 
if (
$make){
///////////////////////
$query    sprintf("SELECT * FROM car_model where car_model_id='$make'");
$result    = @mysql_query($query);
$rowModel    mysql_fetch_array($result);
/////////////////////////
}
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
 
<body>
 
<form id="form1" name="form1" method="post" action="dropdown.php">
 
 
  <select name="make" onChange="document.forms[0].submit()">
    <option value="" selected>Select Make</option>
    <option value="1">Alfa Romero</option>
    <option value="2">Audi</option>
    <option value="3">BMW</option>
    <option value="4">Citroen</option>
  </select>
 
   <select name="model">
    <option value="">Select Model</option>
    <?php do {     ?>
    <option value="<?php echo $rowModel['car_model_id']; ?>"><?php echo $rowModel['car_model']; ?></option>
    <?php    }while ($rowModel mysql_fetch_array($result)); ?>
  </select>
 
 
</form>
</body>
</html>

Last edited by davidj; 02-19-2009 at 08:57 PM..
inflict is offline   Reply With Quote
Old 02-19-2009, 09:10 PM   #2
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

its a notice

this happens because you have not defined your $_POST var before using it

its not wrong but its following coding standard rules and asking if this is what you wanted to do

you need to turn down the sensitivity of the error handling in the php.ini

open the ini file from the WAMP icon under php and locate the error section

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Error handling and logging ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

make sure that its set like the following

error_reporting = E_ALL & ~E_NOTICE
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 02-21-2009, 06:45 PM   #3
shazzi2k
 
Join Date: Feb 2009
Posts: 9
Default

Not sure how i do this, one friend is telling me i put error_reporting = E_ALL & ~E_NOTICE into the PHP script and another is telling me i dont :S

defined your $_POST var before using it (How would i do this?)

Last edited by shazzi2k; 02-21-2009 at 06:55 PM..
shazzi2k is offline   Reply With Quote
Old 02-21-2009, 07:06 PM   #4
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

your error handling is too sensitive

your first friend is correct as i just pointed out

amend your php.ini

your second friend is not wrong however

code standards stipulate that you define your $_POST however its not a requirement with PHP and unless your coding OO you dont need to worry about this

at the top of your script just add $_POST;
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk

Last edited by davidj; 02-21-2009 at 07:11 PM..
davidj is offline   Reply With Quote
Old 02-21-2009, 07:29 PM   #5
shazzi2k
 
Join Date: Feb 2009
Posts: 9
Default

Ok, i put it into the script and it looks like this;

E_ALL & ~E_NOTICE

////////////////////////
$data2 = $_POST[ 'data2' ] ;
$data3 = $_POST[ 'data3' ] ;
$data4 = $_POST[ 'data4' ] ;
$Submit = $_POST[ 'Submit'] ;
$del = $_GET [ 'del' ] ;
////////////////////////

But now when i run it locally i get

Parse error: parse error in C:\wamp\www\Web Root\Test\Images\shazcorp.php on line 7

Line 7 is
$data2 = $_POST[ 'data2' ] ;
shazzi2k is offline   Reply With Quote
Old 02-21-2009, 07:31 PM   #6
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

this bit

E_ALL & ~E_NOTICE

needs to be in your PHP.ini file

not in your script
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 02-21-2009, 07:31 PM   #7
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

follow my resolution above
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 02-21-2009, 08:08 PM   #8
shazzi2k
 
Join Date: Feb 2009
Posts: 9
Default

Woohooo! it worked thanks! But now i have another problem lolz

When i hit delete to remove a record i get

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 ')' at line 1

Line 1 just has <?php

Can you help me Master Chief ?
shazzi2k is offline   Reply With Quote
Old 02-22-2009, 01:45 AM   #9
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

answered in the other post

dont double post
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 02-23-2009, 01:56 PM   #10
siQ
 
Join Date: Feb 2009
Posts: 2
Default Notice still showing

The Notices still appear on the top of my page and on the second drop down. I have tried many combinations of all these thingies but to no avail.

siQ is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:26 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com