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
https://forums.phpfreaks.com/topic/166869-solved-notice-undefined-index-ecid/
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" ;

 

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" ;

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.