soleimanian 0 Report post Posted October 18, 2004 i used below to display my banner<?$db=mysql_connect("localhost","root","");mysql_select_db("ad",$db);$result=mysql_query("select * from ad");$row=mysql_num_rows($result);$imagenum=mysql_query("select * from ad where ID=1");while ($image=mysql_fetch_array($imagenum)) {printf("<a href='$image[1]'><img src='$image[0]' border=0 alt=wallpaper></a>");}?>it run in my pc correctly but at server display below warningWarning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in ....Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in .... Share this post Link to post Share on other sites
lhunath 0 Report post Posted October 19, 2004 Wow, for one, when you put it online, you're using the Online MySQL server. Your username there is not root and you do have a password. At home you probably used your own MySQL server, I'm guessing, since I see little other ways. But you need to change your connect statement so that it can connect to the host's MySQL server. Are you sure you didn't get an error about that..? Change your mysql_connect to: if(!($db=mysql_connect("localhost",$myUserName,$myPassWord))) die("An error occured while trying to connect to the MySQL Database :" . mysql_error($db)); And keep in mind that you should always check for errors like this, after executing a MySQL (or any other function) statement. Don't suppose that everything always works out flawlessly. This way, at least you know where things went wrong. Oh and, if you use select_db, you should select a database, not a table form a database. I'm not sure how your MySQL database works and what it's named, but it looks to me like you're using mysql_select_db to select a table, whereas you need to put your databasename in there (usually something like [username]_[databasename]). Share this post Link to post Share on other sites
Hercco 0 Report post Posted October 23, 2004 Oh and, if you use select_db, you should select a database, not a table form a database. <{POST_SNAPBACK}> He just has a database called ad. And don't forget to put error checking in database select and queries aswell. Like lhunath said you know what caused the errors and makes fixing it a hell of a lot easier. Share this post Link to post Share on other sites
avalon1405241471 0 Report post Posted October 27, 2004 You can definately use username "root" if you have root access to the MySql Server. Which means that you are using a VPS, Dedicated Server or Co-Location Server. Most VSH (Virtual Share Hosting) will not allow that.The following code should work, if it still show an error, let me know. <?php$db= @mysql_connect("localhost","root","rootpassword");if( !$db ) die( "Cannot Connect to Database" );@mysql_select_db("ad",$db);$imagenum = mysql_query("select * from ad where ID=1") or die(mysql_error());$imagenumcount = @mysql_num_rows($imagenum);while ($image = @mysql_fetch_object($imagenum)) {echo "<a href='".$image->imagefilename."'><img src='".$image->imagefilepath."' border=0 alt=wallpaper></a><br><br>";}?> Share this post Link to post Share on other sites
soleimanian 0 Report post Posted October 27, 2004 thank to every bodyi resolve problem Share this post Link to post Share on other sites
football1232131405241471 0 Report post Posted November 1, 2004 good!but i also want 2 no how did u lern how 2 do this stuffbecause i want 2 upload a clan scrip and i need 2 use some sql stuff am so lost lolcan any 1 try and help me Share this post Link to post Share on other sites
lhunath 0 Report post Posted November 1, 2004 http://php.net/manual/en/ref.mysql.php + http://dev.mysql.com/doc/refman/5.6/en/ + Brains + Concentration + Experimentation Share this post Link to post Share on other sites
pedro1405241472 0 Report post Posted November 4, 2004 <?phpmysql_select_db($database_aa, $aa);$query_Recordset1 = "SELECT * FROM xxxxx";$Recordset1 = mysql_query($query_Recordset1, $aa) or die(mysql_error());$row_Recordset1 = mysql_fetch_assoc($Recordset1);$totalRows_Recordset1 = mysql_num_rows($Recordset1);$imagenum = mysql_query("select * from ad where ID=1") or die(mysql_error());$imagenumcount = @mysql_num_rows($imagenum);while ($image = @mysql_fetch_object($imagenum)) {echo "<a href='".$image->imagefilename."'><img src='".$image->imagefilepath."' border=0 alt=wallpaper></a><br><br>";?> Share this post Link to post Share on other sites
Hercco 0 Report post Posted November 5, 2004 http://php.net/manual/en/ref.mysql.php + http://dev.mysql.com/doc/refman/5.6/en/ + Brains + Concentration + Experimentation <{POST_SNAPBACK}> And in case of late night add a coffee maker. AKA programmers best friend. Share this post Link to post Share on other sites
lhunath 0 Report post Posted November 5, 2004 pedro, he solved the problem already, if you have a better solution, paste it, but say why you think it's worth still mentioning it now. Share this post Link to post Share on other sites