dp69_2001 Posted September 16, 2011 Share Posted September 16, 2011 ugh... I'm a total PHP nub and I'm having trouble with: $search_by = $_POST['search_by']; $search = $_post['search']; $dbc = mysqli_connect('xx', 'artofwarsomerset', 'xx', 'artofwarsomerset') or die ('Error connecting to MySQL server'); $query = "SELECT * FROM players WHERE '$search_by' = '$search' "; $result = mysqli_query($dbc,$query) or die("Error: ".mysqli_error($dbc)); echo "<table><tr><td>Player</td><td>city</td><td>alliance</td><td>x</td><td>y</td><td>other</td><td>porters</td><td>conscripts</td><td>Spies</td><td>HBD</td><td>Minos</td><td>LBM</td><td>SSD</td><td>BD</td><td>AT</td><td>Giants</td><td>Mirrors</td><td>Fangs</td><td>ogres</td><td>banshee</td></tr>" ; while ($row = mysqli_fetch_array ($result)) { echo '<tr><td> $row['player'] </td>'; echo '<td> . $row['city']</td>'; echo '<td> . $row['alliance']</td>'; echo '<td> . $row['x']</td>'; echo '<td> . $row['y']</td>'; echo '<td> . $row['other']</td>'; echo '<td> . $row['porter']</td>'; echo '<td> . $row['cons']</td>'; echo '<td> . $row['spy']</td>'; echo '<td> . $row['hbd']</td>'; echo '<td> . $row['mino']</td>'; echo '<td> . $row['lbm']</td>'; echo '<td> . $row['ssd']</td>'; echo '<td> . $row['bd']</td>'; echo '<td> . $row['at']</td>'; echo '<td> . $row['giant']</td>'; echo '<td> . $row['fm']</td>'; echo '<td> . $row['ft']</td>'; echo '<td> . $row['ogre']</td>'; echo '<td> . $row['banshee']</td></tr></table>'; } ?> Error shows up on line 35 but I'm not sure what I've done... Also, the xx's on my dbc statement were on purpose. Current error is: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/content/64/4940664/html/artofwar/browse.php on line 35, I can't figure out where the hell it wants a ;... Link to comment https://forums.phpfreaks.com/topic/247254-simple-database-search-with-multiple-returns/ Share on other sites More sharing options...
Adam Posted September 16, 2011 Share Posted September 16, 2011 You're using a single quote within a single quote string. You need to concatenate the variable into the string: echo '<tr><td>' . $row['player'] . '</td>'; Link to comment https://forums.phpfreaks.com/topic/247254-simple-database-search-with-multiple-returns/#findComment-1269820 Share on other sites More sharing options...
dp69_2001 Posted September 16, 2011 Author Share Posted September 16, 2011 You're using a single quote within a single quote string. You need to concatenate the variable into the string: echo '<tr><td>' . $row['player'] . '</td>'; Believe it or not, even though I totally messed that up on that entire section... That doesn't solve the problem at all. :/ EDIT: Sorry, I guess I was doing the concaten...whatever wrong... I think it should be fixed in a moment, hope it works Thank you. Link to comment https://forums.phpfreaks.com/topic/247254-simple-database-search-with-multiple-returns/#findComment-1269823 Share on other sites More sharing options...
Adam Posted September 16, 2011 Share Posted September 16, 2011 Which is line 35? Link to comment https://forums.phpfreaks.com/topic/247254-simple-database-search-with-multiple-returns/#findComment-1269825 Share on other sites More sharing options...
dp69_2001 Posted September 16, 2011 Author Share Posted September 16, 2011 I'd messed with it and somehow ended up as line #38 I have echo "<table><tr><td>Player</td><td>city</td><td>alliance</td><td>x</td><td>y</td><td>other</td><td>porters</td><td>conscripts</td><td>Spies</td><td>HBD</td><td>Minos</td><td>LBM</td><td>SSD</td><td>BD</td><td>AT</td><td>Giants</td><td>Mirrors</td><td>Fangs</td><td>ogres</td><td>banshee</td></tr>" ; $search_by = $_POST['search_by']; $search = $_post['search']; $dbc = mysqli_connect('xx'); $query = "SELECT * FROM players WHERE '$search_by' = '$search' "; $result = mysqli_query($dbc,$query) or die("Error: " .mysqli_error($dbc)); while ($row = mysqli_fetch_array ($result)) { echo '<tr><td>' . $row['player'] . '</td>'; echo '<td>' . $row['city'] . '</td>'; echo '<td>' . $row['alliance'] . '</td>'; echo '<td>' . $row['x'] . '</td>'; echo '<td>' . $row['y'] . '</td>'; echo '<td>' . $row['other'] . '</td>'; echo '<td>' . $row['porter'] . '</td>'; echo '<td>' . $row['cons'] . '</td>'; echo '<td>' . $row['spy'] . '</td>'; echo '<td>' . $row['hbd'] . '</td>'; echo '<td>' . $row['mino'] . '</td>'; echo '<td>' . $row['lbm'] . '</td>'; echo '<td>' . $row['ssd'] . '</td>'; echo '<td>' . $row['bd'] . '</td>'; echo '<td>' . $row['at'] . '</td>'; echo '<td>' . $row['giant'] . '</td>'; echo '<td>' . $row['fm'] . '</td>'; echo '<td>' . $row['ft'] . '</td>'; echo '<td>' . $row['ogre'] . '</td>'; echo '<td>' . $row['banshee'] . '</td></tr></table>'; } ?> Now, it's returning data... But for some reason, it either returns no data, or all of the data... So I've probably messed it up somehow... Now, it's not displaying in the table :/ guess I should study a bit more before trying something which seems to be rather complicated. But, I was kind of excited to give it a try... Link to comment https://forums.phpfreaks.com/topic/247254-simple-database-search-with-multiple-returns/#findComment-1269831 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.