Lots of Errors! [SOLVED]

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
User avatar
OoZI
Posts: 109
Joined: Mon Jan 02, 2012 4:22 pm

Lots of Errors! [SOLVED]

Post 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
Last edited by OoZI on Thu Mar 01, 2012 1:08 am, edited 1 time in total.
-OoZI

My Blog
User avatar
Chris
Posts: 1580
Joined: Wed Sep 30, 2009 7:22 pm

Re: Lots of Errors!

Post 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.
Fighting for peace is declaring war on war. If you want peace be peaceful.
casino
Posts: 22
Joined: Thu Feb 23, 2012 9:44 pm

Re: Lots of Errors!

Post 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.
User avatar
OoZI
Posts: 109
Joined: Mon Jan 02, 2012 4:22 pm

Re: Lots of Errors!

Post 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
-OoZI

My Blog
User avatar
MikeD
Posts: 294
Joined: Thu Sep 08, 2011 4:28 am

Re: Lots of Errors!

Post 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 }
User avatar
OoZI
Posts: 109
Joined: Mon Jan 02, 2012 4:22 pm

Re: Lots of Errors!

Post by OoZI »

Okay, Thanks! I figured everything out!
-OoZI

My Blog
Post Reply

Return to “Beginner Help and Support”