Jump to content

[SOLVED] query database not working


mbrown

Recommended Posts

    <?php

	include 'dbconnect.php';

	$Query = "SELECT ID, Age, Month, Day, Year, Hometown, State, Graduation, Certificate, Associates, Bachelors, Study, GPA FROM survey WHERE = Age = '21'";

	$Result = mysqli_query ($db $Query) or die("<p>Unable to execute the query.</p>"
	. "<p>Error Code</p>" . mysqli_errno($db) . ": " . mysqli_error($db)) . "</p>";

	echo "<p>Successfully executed the query.>/p>";
	mysqli_close($db);


?>

 

it is throwing this error: Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\CIT250\Project\assignment3\age.php on line 15

 

All I want is to display the information in a table. Yes I know I dont have the table set up yet but thats life at the moment. One step at a time.

Link to comment
Share on other sites

Don't know if this is it, but give it a shot:

 

<?php
include('dbconnect.php');

$Query = "SELECT ID, Age, Month, Day, Year, Hometown, State, Graduation, Certificate, Associates, Bachelors, Study, GPA FROM survey WHERE Age = '21'";

$Result = mysqli_query ($db $Query) or die("<p>Unable to execute the query.</p>" . "<p>Error Code</p>" . mysqli_errno($db) . ": " . mysqli_error($db) . "</p>");

echo "<p>Successfully executed the query.>/p>";
mysqli_close($db);
?>

Link to comment
Share on other sites

It's in your WHERE clause:

 

 

    <?php

	include 'dbconnect.php';

	$Query = "SELECT ID, Age, Month, Day, Year, Hometown, State, Graduation, Certificate, Associates, Bachelors, Study, GPA FROM survey WHERE Age = '21'";

	$Result = mysqli_query ($db $Query) or die("<p>Unable to execute the query.</p>"
	. "<p>Error Code</p>" . mysqli_errno($db) . ": " . mysqli_error($db)) . "</p>";

	echo "<p>Successfully executed the query.>/p>";
	mysqli_close($db);


?>

 

same error: Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\CIT250\Project\assignment3\age.php on line 15

 

Yelling at the following code

 

	$Result = mysqli_query ($db $Query) or die("<p>Unable to execute the query.</p>"

[code]

[/code]

Link to comment
Share on other sites

Yeah, there's a lot of typos and stuff in your code. You should really look more closely at it. Here's my fix:

 

    <?php

	include 'dbconnect.php';

	$Query = "SELECT ID, Age, Month, Day, Year, Hometown, State, Graduation, Certificate, Associates, Bachelors, Study, GPA FROM survey WHERE Age = '21'";

	$Result = mysql_query ($Query,$db) or die("<p>Unable to execute the query.</p>"
	. "<p>Error Code</p>" . mysql_error($db) . ": " . mysql_error($db) . "</p>");

	echo "<p>Successfully executed the query.</p>";
	mysql_close($db);


?>

Link to comment
Share on other sites

Sorry...use this...

 

<?php
include('dbconnect.php');

$Query = "SELECT ID, Age, Month, Day, Year, Hometown, State, Graduation, Certificate, Associates, Bachelors, Study, GPA FROM survey WHERE Age = '21'";

$Result = mysqli_query ($db, $Query) or die("<p>Unable to execute the query.</p>" . "<p>Error Code</p>" . mysqli_errno($db) . ": " . mysqli_error($db) . "</p>");

echo "<p>Successfully executed the query.>/p>";
mysqli_close($db);
?>

Link to comment
Share on other sites

Here's a list of all the errors I saw:

 

an extra "=" in the where clause

using "mysqli_..." instead of "mysql_..." (added an "i")

")" in the wrong place in the die() statement

used ">" instead of "<" in the successful echo statement

 

mysqli() is a new PHP extension.  Look it up before you go correcting people.

Link to comment
Share on other sites

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.