Login | Register | FAQ
Anonymous

MYSQL FETCH ARRAY HELP!!!!!

+ Post a reply

Page 1 of 1


MYSQL FETCH ARRAY HELP!!!!!

by soccerwebsitemaker » Fri May 11, 2012 12:57 am

Every single site I make has an error with mysql_fetch_array. Can anyone help me out this time?

Code:





<?php

$connection = mysql_connect('mysql16.000webhost.com', 'my username', 'my password') or die (mysql_error ());

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

$username = $_POST['alusername'];

$password = $_POST['alpassword'];

$strSQL = "SELECT * FROM Admin Users WHERE Username == $username AND Password == $password";

$rs = mysql_query($strSQL, $connection);

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

echo $row['Username'] . "<br />";

}

// Close the database connection
mysql_close();
?>

<a href="http://pentagramproductions.uphero.com/Pentagram%20Productions.php">Back to home page</a>



THANK YOU for reading and thank you even more if you reply with 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: MYSQL FETCH ARRAY HELP!!!!!

by XainPro » Fri May 11, 2012 4:21 am

remove double equal i think that's the problem but from which page you copied this code could you please mention ?

$strSQL = "SELECT * FROM Admin Users WHERE Username == $username AND Password == $password";

it should be single equal.
i have not tested it but i think the problem is with this equal sign.
User avatar

XainPro

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

Re: MYSQL FETCH ARRAY HELP!!!!!

by soccerwebsitemaker » Fri May 11, 2012 12:30 pm

I copied the code from the Html.net PHP tutorial.


I tried putting single quotes, it does not work



It still says "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/a7899310/public_html/stuff/login.php on line 17"
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: MYSQL FETCH ARRAY HELP!!!!!

by XainPro » Fri May 11, 2012 4:33 pm

could you please share the link of that page ?
User avatar

XainPro

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

Re: MYSQL FETCH ARRAY HELP!!!!!

by soccerwebsitemaker » Fri May 11, 2012 6:08 pm

Link to my site where broken code exists:


http://www.pentagramproductions.uphero.com



Link to where I found my code:

http://html.net/tutorials/php/lesson20.php
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: MYSQL FETCH ARRAY HELP!!!!!

by XainPro » Sat May 12, 2012 9:22 am

ok i found the problem.
The Problem is in your query
And database architecture
1.Please Exclude spaces between table name do not enter space between table name
like you have enter Admin Users i think its your table name with space in it. You should avoid space to prevent conflict.
2. You should not enter double equal sign (==) in query.
3.You should also include single quote ('') when using variable in query such as $username
after correction your query should look like below

$strSQL = "SELECT * FROM AdminUsers WHERE Username = '$username' AND Password = '$password'"
User avatar

XainPro

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

Re: MYSQL FETCH ARRAY HELP!!!!!

by soccerwebsitemaker » Mon May 14, 2012 12:27 am

Nice Job, thanks again.

(Just wait, I'll get another problem in a few days...)

probably
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: MYSQL FETCH ARRAY HELP!!!!!

by XainPro » Mon May 14, 2012 5:12 am

You are Welcome.
I hope you will not face any trouble in future but if you do, i am on hold you can get help any time you want.
Happy Learning..
User avatar

XainPro

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

Re: MYSQL FETCH ARRAY HELP!!!!!

by vergar » Sun Apr 21, 2019 4:18 pm

посв231.6таблCHAPРоссUndiАрцрJerzотдеШуреYourSkagSifrFiskрабоЮсупВяткUnitСемесловParkSoulHits
SPORMariStopYvesMexoMariVinoCafeGabrMoisTerrRobeDreaсертMythStanPerpBarbMaxtstopCanoTranкниг
CreoDonaNadiRandЖадь1280LEGOТкалвперRogeIronLowlMornRobeJameАлекCherIsaaEncoМвкдСодеAmarХерл
EtniDiamHarrGeniWindAlexБаркAlexAquaGmaxAndrBaldDigiChecразгTatoKaryвремЗареEHLPTattSviaDavi
крас9056Arts03-1RHZNOptiDrBrLomoЩербExceДобрSvagRolaСысоSergHistсловMichGarmCracDaviEverMicr
MartпотеWordпродорначернZanuRozaPricPeteБрагсерт8327PolaMariРазмРоссРН22ARAGзначВоскгенеClas
BrigValiпечаотлидетаDisnPycaElviWindWindсклаBrauClorGranTriohaveЛитРЛитРJeweЛитРJameInteЛитР
угроНатхМартВолипереRogeBookтетрHearНезаValeЕженЕрмоQuesSparЛеонBlacФэшаBabyJacqЛениAlanврач
OtfrБортситуInsiXXXIКорчкотоWindлицаНикоМироАрноНосоДереSPECЗинчМищеNB00СивовычиПузипродпрод
продWratИллюBabyМошкBittДрозналоRobeVadiМироNenaРедьМатвKnow
User avatar

vergar
Online

  • Posts: 35750
  • Joined: Tue Apr 16, 2019 2:34 pm


+ Post a reply

Page 1 of 1