Jump to content

Recommended Posts

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

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.

 

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

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.