jim.davidson Posted April 27, 2010 Share Posted April 27, 2010 I got mySQL table with a field called title I want to get a recordset of just titles of a given letter. $letter = 'B'; SELECT * FROM dvds WHERE substr(title,1,1) = $letter ORDER BY title ASC; I get this error Parse error: parse error, unexpected T_STRING What am I doing wrong? Any help will be appreciated Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted April 27, 2010 Share Posted April 27, 2010 The error is a php error. It would take seeing your actual php code in order to help you. If that is your actual php code, it is not php code. That is one line of php code followed by a sql statement. Quote Link to comment Share on other sites More sharing options...
jim.davidson Posted April 27, 2010 Author Share Posted April 27, 2010 Ok here's the code, I use this all the time the only difference is the select command. That's why I assumed it to be something in the query that's wrong. <?php $letter = 'A'; $currentPage = $_SERVER["PHP_SELF"]; $maxRows_getList = 18; $pageNum_getList = 0; if (isset($_GET['pageNum_getList'])) { $pageNum_getList = $_GET['pageNum_getList']; } $startRow_getList = $pageNum_getList * $maxRows_getList; mysql_select_db($my_database, $my_id); $query_getList = "SELECT * FROM dvds, dvd_genres, dvd_ratings WHERE substr(dvds.title,1,1)=$letter AND dvds.rating=dvd_ratings.rating_id AND dvds.genres=dvd_genres.genres_id ORDER BY dvds.title ASC"; $query_limit_getList = sprintf("%s LIMIT %d, %d", $query_getList, $startRow_getList, $maxRows_getList); $getList = mysql_query($query_limit_getList, $my_id) or die(mysql_error()); $row_getList = mysql_fetch_assoc($getList); if (isset($_GET['totalRows_getList'])) { $totalRows_getList = $_GET['totalRows_getList']; } else { $all_getList = mysql_query($query_getList); $totalRows_getList = mysql_num_rows($all_getList); } $totalPages_getList = ceil($totalRows_getList/$maxRows_getList)-1; $queryString_getList = ""; if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, "pageNum_getList") == false && stristr($param, "totalRows_getList") == false) { array_push($newParams, $param); } } ?> Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted April 27, 2010 Share Posted April 27, 2010 The code you posted does not produce the error you posted. Without the actual code and the error message with line number information, it is simply not possible to help with what is wrong with your code. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.