SQLTeam.com | Weblogs | Forums

PHP SQL Help

#1

Hi Im trying to do some database sql stuff and basically i've got a html form label and the user selects an item and from a database im trying to select a time that is only corresponding to the chosen item (I hope that makes sense) . The two lines below are how im doing it but i get access violation: 1064 because of the "where Course_Title = $selected");". Any recommendations on why?

$$selected = $_REQUEST['chosenCourse']; (I know there's 2 dollar signs there the thing lets me have 2 or none?)

$stmt = $GLOBALS["pdo"]->prepare("SELECT Times from courses where Course_Title = $selected");

0 Likes

#2

I know very little about PHP but when I've used it the prepare has a replacement variable indicated by a ? and then bind the value to that then execute.
Could be that what you are doing is combining the prepare and bind but it's worth trying to separate them.

0 Likes