mbrown Posted September 18, 2008 Share Posted September 18, 2008 <?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 https://forums.phpfreaks.com/topic/124865-solved-query-database-not-working/ Share on other sites More sharing options...
F1Fan Posted September 18, 2008 Share Posted September 18, 2008 It's in your WHERE clause: $Query = "SELECT ID, Age, Month, Day, Year, Hometown, State, Graduation, Certificate, Associates, Bachelors, Study, GPA FROM survey WHERE Age = '21'"; Link to comment https://forums.phpfreaks.com/topic/124865-solved-query-database-not-working/#findComment-645095 Share on other sites More sharing options...
troy_mccormick Posted September 18, 2008 Share Posted September 18, 2008 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 https://forums.phpfreaks.com/topic/124865-solved-query-database-not-working/#findComment-645096 Share on other sites More sharing options...
mbrown Posted September 18, 2008 Author Share Posted September 18, 2008 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 https://forums.phpfreaks.com/topic/124865-solved-query-database-not-working/#findComment-645100 Share on other sites More sharing options...
F1Fan Posted September 18, 2008 Share Posted September 18, 2008 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 https://forums.phpfreaks.com/topic/124865-solved-query-database-not-working/#findComment-645101 Share on other sites More sharing options...
troy_mccormick Posted September 18, 2008 Share Posted September 18, 2008 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 https://forums.phpfreaks.com/topic/124865-solved-query-database-not-working/#findComment-645103 Share on other sites More sharing options...
F1Fan Posted September 18, 2008 Share Posted September 18, 2008 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 Link to comment https://forums.phpfreaks.com/topic/124865-solved-query-database-not-working/#findComment-645104 Share on other sites More sharing options...
troy_mccormick Posted September 18, 2008 Share Posted September 18, 2008 You do know that mysqli are PHP functions, right? Link to comment https://forums.phpfreaks.com/topic/124865-solved-query-database-not-working/#findComment-645105 Share on other sites More sharing options...
DarkWater Posted September 18, 2008 Share Posted September 18, 2008 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 https://forums.phpfreaks.com/topic/124865-solved-query-database-not-working/#findComment-645106 Share on other sites More sharing options...
mbrown Posted September 18, 2008 Author Share Posted September 18, 2008 Got everything working with troy_mccormick's help Now to make it look pretty Link to comment https://forums.phpfreaks.com/topic/124865-solved-query-database-not-working/#findComment-645107 Share on other sites More sharing options...
F1Fan Posted September 18, 2008 Share Posted September 18, 2008 Interesting. I did a search for it before I posted, as you suggest, but it forwarded me to the regular mysql functions. My bad, and weird that it wouldn't have sent me to the mysqli. Again, my bad. Link to comment https://forums.phpfreaks.com/topic/124865-solved-query-database-not-working/#findComment-645108 Share on other sites More sharing options...
troy_mccormick Posted September 18, 2008 Share Posted September 18, 2008 Got everything working with troy_mccormick's help Now to make it look pretty Glad it worked out. Be sure to mark this post as solved (bottom left of the page) Link to comment https://forums.phpfreaks.com/topic/124865-solved-query-database-not-working/#findComment-645110 Share on other sites More sharing options...
DarkWater Posted September 18, 2008 Share Posted September 18, 2008 Interesting. I did a search for it before I posted, as you suggest, but it forwarded me to the regular mysql functions. My bad, and weird that it wouldn't have sent me to the mysqli. Again, my bad. K. Link to comment https://forums.phpfreaks.com/topic/124865-solved-query-database-not-working/#findComment-645112 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.