Login | Register | FAQ
Anonymous

PHP error mysql_fetch_array

+ Post a reply

8 posts Page 1 of 1


PHP error mysql_fetch_array

by soccerwebsitemaker » Mon Apr 23, 2012 12:00 am

<?php

mysql_connect("mysql1.000webhost.com", "username", "password") or die (mysql_error ());

mysql_select_db("database") or die(mysql_error());

$ufcc = "SELECT * FROM table1";

$uic = "SELECT * FROM table2";

$rs = mysql_query($ufcc);

        while($row = mysql_fetch_array($rs)) {

$username = $row['Username'];

echo '<p id="usernamep">'.$row['Username'].'</p>';

 }

mysql_close();

?>


the part in bold is the area that the server said was an error! please help
User avatar

soccerwebsitemaker

  • Posts: 139
  • Joined: Sat Dec 31, 2011 6:25 pm
--
Coins. Profile. Games. Chat. Fun.

CoinAwards.

Check it out at http://www.coinawards.net63.net/

Re: PHP error mysql_fetch_array

by XainPro » Mon Apr 23, 2012 5:04 am

You PHP code is all right and does not have any error in it please do check that is there any table nameed table1 in your database and it has some records in it.
User avatar

XainPro

  • Posts: 3583
  • Joined: Fri Feb 17, 2012 8:10 pm

Re: PHP error mysql_fetch_array

by soccerwebsitemaker » Mon Apr 23, 2012 9:03 pm

I changed the name of table to protect privacy or hacking into account.

I'll provide all code if u see any errors...




<!DOCTYPE html>

<html>

<head>

<title>Welcome to CoinAwards</title>

<link rel="stylesheet" href="structure/home.css" />

<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js'></script>

<script src="structure/jQueryEase.js"></script>

<script src="structure/home.js"></script>

</head>

<body>

<header>

<hgroup>

<h1 id="coin-awards-welcome">Welcome to CoinAwards!</h1>

<h2 id="coin-awards-welcome-subtitle">A place where you can <span class="highlite-blue">earn coins</span> and <span class="highlite-blue">trade them
</span> in for cool <span class="highlite-blue">virtual prizes</span>!</h2>

</hgroup>

</header>

<section id="loginbox">

<div id="logintab">

Login

</div>

<div id="registertab">

Register

</div>

<form id="loginform" method="post" action="structure/loginpage.php">

<br>

<br>

<h3 class="loginheading">Login</h3>

<label for"lusername">Username</label><input type="text" class="lusername" name="lusername" />

<br>

<br>

<label for="lpassword">Password</label><input type="password" class="lpassword" name="lpassword" />

<br>

<br>

<input type="submit" value="Login" class="lsubmit" />

</form>

<form id="registerform" method="post" action="structure/registerpage.php">

<br>

<br>

<h3 class="registerheading">Register</h3>

<label for="rusername">Username</label><input type="text" class="rusername" name="rusername" />

<br>

<br>

<label for="remail">Email</label><input type="email" class="remail" name="remail" />

<br>

<br>

<label for="rpassword">Password</label><input type="password" class="rpassword" name="rpassword" />

<br>

<br>

<label for="rcpassword">Check Pass</label><input type="password" class="rcpassword" />

<input type="submit" value="Register" class="rsubmit" />

</form>

</section>

<section id="mainMenu" style="z-index: 2;">

<ul>
<li id="li1" class="green">
<p><a href="../Advance_To_Coin_Awards.php">Home</a></p>
<a href="../Advance_To_Coin_Awards.php"><div class="subtext">Home</div></a>
</li>
<li id="li2" class="yellow">
<p><a href="structure/whatisthis.php">What is this?</a></p>
<a href="structure/whatisthis.php"><div class="subtext">What is this?</div></a>
<a href="structure/moreinfo.php"><div class="subtext">More Info</div></a>
<a href="structure/tipsandtricks.php"><div class="subtext">Tips and Tricks</div></a>
</li>
<li id="li3" class="red">
<p><a href="structure/earncoins.php">Earn Coins</a></p>
<a href="structure/earncoins.php"><div class="subtext">Earn Coins</div></a>
<a href="structure/achievements.php"><div class="subtext">Achievements</div></a>
</li>
<li id="li4" class="blue">
<p><a href="structure/chooseawards.php">Choose Awards</a></p>
<a href="structure/chooseawards.php"><div class="subtext">Choose Awards</div></a>
<a href="structure/wishlist.php"><div class="subtext">Wish List</div></a>
<a href="structure/buyinghistory.php"><div class="subtext">Buying History</div></a>
</li>
<li id="li5" class="purple">
<p><a href="structure/profile.php">Profile</a></p>
<a href="structure/profile.php"><div class="subtext">Profile</div></a>
<a href="structure/spruceitup.php"><div class="subtext">Spruce it up</div></a>
<a href="structure/compare.php"><div class="subtext">Compare</div></a>
</li>
<li id="li6" class="brown">
<p><a href="structure/allactivities.php">All Activities</a></p>
<a href="structure/allactivities.php"><div class="subtext">All Activities</div></a>
<a href="structure/games.php"><div class="subtext">Games</div></a>
<a href="structure/chatroom.php"><div class="subtext">Chat Room</div></a>
</li>
</ul>

</section>

<section id="home-content">

<h2 id="home-content-title">Play games, chat, and earn coins!</h2>

<p id="content-1">Own a customizable profile that sports unlockable parts through the spending of coins, which can be earned by spending time on
the site, finding secrets, completing achievements, and more. You'll have the chance to play games, chat, and do more by visiting this site. While you
are enjoying the features of this site, you will gain coins - currency. You can spend these coins on an always-updated shop. While it is possible to still
enjoy this site without logging in (games, chat, etc.), creating an account will help you enjoy the full benefits of your experience here - why not? -
it's free and fun!</p>

</section>

<footer>

<p id="footercrp">Copyright © CoinAwards 2012 | Hosted for free under <a href="http://www.000webhost.com" style="color: #333366;">000webhost</a>. Site
Version 1.1 by Austin Stout. V 1.1 includes bonus screen resolution support as well as tablet support.</p>

</footer>

<div id="lsidepanel">

</div>

<div id="rsidepanel">

</div>

<?php

mysql_connect("mysql1.000webhost.com", "username", "password") or die (mysql_error ());

mysql_select_db("database") or die(mysql_error());

$ufcc = "SELECT * FROM table1";

$uic = "SELECT * FROM table2";

$rs = mysql_query($ufcc);

while($row = mysql_fetch_array($rs)) {

$username = $row['Username'];

echo '<p id="usernamep">'.$row['Username'].'</p>';

}

mysql_close();

?>

</body>

</html>
User avatar

soccerwebsitemaker

  • Posts: 139
  • Joined: Sat Dec 31, 2011 6:25 pm
--
Coins. Profile. Games. Chat. Fun.

CoinAwards.

Check it out at http://www.coinawards.net63.net/

Re: PHP error mysql_fetch_array

by XainPro » Wed Apr 25, 2012 5:14 pm

Bro all your code is perfect please tell me what problem you are facing ?
i only found 1 problem in your html code which is not related to your problem
you did not entered name for this field in your html

Code: Select all
<label for="rcpassword">Check Pass</label><input type="password" class="rcpassword" />


and fields name in database are case sensitive please do check in yout table the Username field exist and its U is upper case.
Regards,
Xain Pro
User avatar

XainPro

  • Posts: 3583
  • Joined: Fri Feb 17, 2012 8:10 pm

Re: PHP error mysql_fetch_array

by soccerwebsitemaker » Wed Apr 25, 2012 11:08 pm

Well, it gives me an error message like this:

Parse error: syntax error, unexpected T_STRING in /home/a7347456/public_html/Advance_To_Coin_Awards.php on line 185



my host is 000webhost.com...

do you know anything about this?

And yes, I've checked a million times, the database names match.
User avatar

soccerwebsitemaker

  • Posts: 139
  • Joined: Sat Dec 31, 2011 6:25 pm
--
Coins. Profile. Games. Chat. Fun.

CoinAwards.

Check it out at http://www.coinawards.net63.net/

Re: PHP error mysql_fetch_array

by XainPro » Thu Apr 26, 2012 12:43 pm

paste the lines from
/Advance_To_Coin_Awards.php file
on line 120 to 190 there is a syntax problem in your file :P
User avatar

XainPro

  • Posts: 3583
  • Joined: Fri Feb 17, 2012 8:10 pm

120-190 code...

by soccerwebsitemaker » Thu Apr 26, 2012 11:59 pm

here ya go...



(starting from my estimate of where line 120 is...)




<section id="home-content">

<h2 id="home-content-title">Play games, chat, and earn coins!</h2>

<p id="content-1">Own a customizable profile that sports unlockable parts through the spending of coins, which can be earned by spending time on
the site, finding secrets, completing achievements, and more. You'll have the chance to play games, chat, and do more by visiting this site. While you
are enjoying the features of this site, you will gain coins - currency. You can spend these coins on an always-updated shop. While it is possible to still
enjoy this site without logging in (games, chat, etc.), creating an account will help you enjoy the full benefits of your experience here - why not? -
it's free and fun!</p>

</section>

<footer>

<p id="footercrp">Copyright © CoinAwards 2012 | Hosted for free under <a href="http://www.000webhost.com" style="color: #333366;">000webhost</a>. Site
Version 1.1 by Austin Stout. V 1.1 includes bonus screen resolution support as well as tablet support.</p>

</footer>

<div id="lsidepanel">

</div>

<div id="rsidepanel">

</div>

<?php

mysql_connect("mysql1.000webhost.com", "username", "password") or die (mysql_error ());

mysql_select_db("database") or die(mysql_error());

$strSQL = 'SELECT * FROM Users_For_CoinAwards';

$uic = 'SELECT * FROM User_Info';

$rs = mysql_query($strSQL);

        while($row = mysql_fetch_array($rs)) {

$username = $row['Username'];

echo '<p id="usernamep">"Welcome, " . $username</p>';

 }

$rs2 = mysql_query($uic);

while($row = mysql_fetch_array($rs2)) {

$coins = $row['Coins'];

echo '<p id="coinsp">'.$row['Coins'].'</p>';

}

mysql_close();

?>

</body>

</html>
User avatar

soccerwebsitemaker

  • Posts: 139
  • Joined: Sat Dec 31, 2011 6:25 pm
--
Coins. Profile. Games. Chat. Fun.

CoinAwards.

Check it out at http://www.coinawards.net63.net/

Re: PHP error mysql_fetch_array

by XainPro » Fri Apr 27, 2012 8:24 pm

well bro estimation will not work here open your file in
Notepad++ software which is open source and free it will tell you the exact line number
you can download Notepad++ from this link
http://notepad-plus-plus.org/download/v6.1.2.html
i am sure it would be very small syntax mistake.
User avatar

XainPro

  • Posts: 3583
  • Joined: Fri Feb 17, 2012 8:10 pm


+ Post a reply

Page 1 of 1

?>