Page 1 of 1

Lots of Errors! [SOLVED]

Posted: Wed Feb 29, 2012 8:54 pm
by OoZI
Hey, guys... Long time no see. I've been working on a studying tool similar to Quizlet.com. I will be using it for Spanish Class. Anyway, I am having trouble, I will post my Scripts and errors, and I hope you guys can help.

connect.php

Code: Select all

<?php

$db = mysqli_connect("localhost","admin","test","cuckle13") or die("Could Not Connect");
if(!db)
die("No Database");
if(!mysqli_select_db("test",$db))
die("No Database Selected");
?>

Error:
( ! ) Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user 'admin'@'localhost' (using password: YES) in C:\wamp\www\Spanish\connect.php on line 3
Call Stack
# Time Memory Function Location
1 0.0020 365840 {main}( ) ..\connect.php:0
2 0.0020 366080 mysqli_connect ( ) ..\connect.php:3
Could Not Connect





Process.php

Code: Select all

<?php
include 'connect.php';
?>

<?php
$query="SELECT * FROM QandA ORDER BY rand() LIMIT 1 COUNT(question);
$query2=mysql_query($query) or die("Error, Unable to query Database");
$query3=mysql_fetch_array($query2);

$question = $query3['question'];
$answer = $query3['answer'];
?>
<?php
function createanswerbox()
{
echo '<form>
<input type=text name= <?php echo $question; ?>>
</form>';

$qcount=['COUNT(question)']
$akcount=0

Do
{
echo $question;
echo "<br />";
createanswerbox();
echo "<br />";
$akcount++
}
While ($akcount <= $qcount);
?>


Error:( ! ) Parse error: syntax error, unexpected T_STRING in C:\wamp\www\Spanish\process.php on line 7

Re: Lots of Errors!

Posted: Wed Feb 29, 2012 9:58 pm
by Chris
First, username is root, not admin (unless you changed it) and you shouldn't need a password (unless you changed that).

Second, as you might notice, half of your code has turned red. Look at the line where it started and look at the second and realize it doesn't stop.. When it should. Basically you forgot a ".

Code: Select all

$query="SELECT * FROM QandA ORDER BY rand() LIMIT 1 COUNT(question)"; 
Do you not use a more advanced text editor? My advice would be to use notepad++ if you want a free one. Sublimetext if you want a good one.

Re: Lots of Errors!

Posted: Wed Feb 29, 2012 11:22 pm
by casino
Well the first thing I noticed was

Code: Select all

<?php

$db = mysqli_connect("localhost","admin","test","cuckle13") or die("Could Not Connect");

?>
Unless you changed your username and password it should look more like this:

Code: Select all

<?php

$db = mysqli_connect("localhost","root","") or die("Could Not Connect");

?>


I'm not sure what cuckle13 is but it doesn't look like it belongs.

Re: Lots of Errors!

Posted: Wed Feb 29, 2012 11:59 pm
by OoZI
Cuckle13 was the password... Here is my new Code, and errors.

Code: Select all

<?php
include 'connect.php';
?>

<?php
$query="SELECT * FROM QandA ORDER BY rand() LIMIT 1 COUNT(question)";
$query2=mysql_query($query) or die("Error, Unable to query Database");
$query3=mysql_fetch_array($query2);

$question = $query3['question'];
$answer = $query3['answer'];
function createanswerbox()
{
echo '<form>
<input type=text name= <?php echo $question; ?>>
</form>';

$qcount='COUNT(question)';
$akcount=0;

Do
{
echo $question;
echo "<br />";
createanswerbox();
echo "<br />";
$akcount++;
}
While ($akcount <= $qcount);
?>
Error:( ! ) Parse error: syntax error, unexpected $end in C:\wamp\www\Spanish\process.php on line 30

Re: Lots of Errors!

Posted: Thu Mar 01, 2012 12:17 am
by MikeD
OoZI wrote:Cuckle13 was the password... Here is my new Code, and errors.

Code: Select all

<?php
include 'connect.php';
?>

<?php
$query="SELECT * FROM QandA ORDER BY rand() LIMIT 1 COUNT(question)";
$query2=mysql_query($query) or die("Error, Unable to query Database");
$query3=mysql_fetch_array($query2);

$question = $query3['question'];
$answer = $query3['answer'];
function createanswerbox()
{
echo '<form>
<input type=text name= <?php echo $question; ?>>
</form>';

$qcount='COUNT(question)';
$akcount=0;

Do
{
echo $question;
echo "<br />";
createanswerbox();
echo "<br />";
$akcount++;
}
While ($akcount <= $qcount);
?>
Error:( ! ) Parse error: syntax error, unexpected $end in C:\wamp\www\Spanish\process.php on line 30
you didnt close your function with a bracket }

Re: Lots of Errors!

Posted: Thu Mar 01, 2012 1:08 am
by OoZI
Okay, Thanks! I figured everything out!