Dreamweaver Club Forums

Dreamweaver Club Forums (http://www.dreamweaverclub.com/forum//index.php)
-   Video Tutorials (http://www.dreamweaverclub.com/forum//forumdisplay.php?f=180)
-   -   Creating Dynamic Dropdowns Tut Error (http://www.dreamweaverclub.com/forum//showthread.php?t=31111)

inflict 02-19-2009 08:14 PM

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?


PHP Code:

$make    =    $_POST['make'];
if (
$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">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<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 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)); ?>

davidj 02-19-2009 09:10 PM

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

shazzi2k 02-21-2009 06:45 PM

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

davidj 02-21-2009 07:06 PM

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;

shazzi2k 02-21-2009 07:29 PM

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


$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' ] ;

davidj 02-21-2009 07:31 PM

this bit


needs to be in your PHP.ini file

not in your script

davidj 02-21-2009 07:31 PM

follow my resolution above

shazzi2k 02-21-2009 08:08 PM

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 :D?

davidj 02-22-2009 01:45 AM

answered in the other post

dont double post

siQ 02-23-2009 01:56 PM

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.


All times are GMT. The time now is 07:02 PM.

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