Jump to content

[SOLVED] Notice: Undefined index: ecid


egiblock

Recommended Posts

i have a javascript that passes a variabe from a form to another window for processing..

 

form:

...

<form name="CourseSelection">

<select name="selectedCourseID" onChange="pullCourse();" id="selectedCourseID">

<option value="0" selected>Select a Course</option>

.......

 

pullcourses.js:

........

ajaxRequest.open("GET", "geteventtoaddscore.php?ecid=" + document.getElementById('selectedCourseID').value, true);

........

 

it passes the line:

 

http://localhost/test1/geteventtoaddscore.php?ecid=3

 

 

getevent...php:

 

<?php

$ecid = $_POST['ecid'];

 

mysql_select_db($database_golfscoring, $golfscoring);

$query_EventListing = "SELECT * FROM tbl_events WHERE $ecid = tbl_events.eventCourseID" ;

 

 

it is throwing the error from the  above sql statement.

 

 

 

 

 

Notice: Undefined index: ecid in C:\wamp\www\test1\geteventtoaddscore.php on line 4

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 '= tbl_events.eventCourseID' at line 1

 

Link to comment
Share on other sites

edit

You're using GET , not POST to send the data.  Change it to post, or change the line below to GET

 

you should sanitize your input!

$ecid = (int) $_POST['ecid']; 

 

Isn't this last part backwards?

$query_EventListing = "SELECT * FROM tbl_events WHERE $ecid = tbl_events.eventCourseID" ;

instead:

$query_EventListing = "SELECT * FROM tbl_events WHERE tbl_events.eventCourseID = $ecid" ;

 

Link to comment
Share on other sites

here's the final code that worked.

 

thanks for the help.

 

this php stuff is all new to me

 

 

$ecid = $_GET['ecid']; 

mysql_select_db($database_golfscoring, $golfscoring);
$query_EventListing = "SELECT * FROM tbl_events WHERE tbl_events.eventCourseID = $ecid" ;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.