tkolbeck Posted March 1, 2007 Share Posted March 1, 2007 I am trying to set a member system and I have to run the install of the script to set up the database automatically and I keep getting this error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/www/bbbshops.com/install.php on line 120 can someone help me with the code or just wright up the code to just insert it into mysql databse to create it because I am a beginner with this stuff. Here is my code:(uzzisofts code) <?php /****************************************************************************** * Install Script * ------------------------------ * Filename: install.php * Project: Uzzisoft - PHP Simple Member System * By: Alejandro(Alex) Iannuzzi * Company: Uzzi Soft * Copyright: © 2004 Uzzi Soft - Alejandro(Alex) Iannuzzi * Website: http://www.uzzisoft.cjb.net * Email: alexiannuzzi02@hotmail.com * License: Freeware * Version: 1.0.2.1 * Build Date: 2004-05-10 * * If you find bugs/errors/anything else you would like to point to out * to us please feel free to contact us. * * What it does: * Creates a new database and two new tables for this project * * How it does it: * Gets the values from the form. Checks if they are empty. Connects * to the MySQL server using the values from the form. * Creates the phpsms database. Creates the tables userdata and usersonline. * Checks to see if they have rows and if they do print installation * complete else print that there was a error. * *****************************************************************************/ ?> <html> <head> <title>Installation of Uzzi Soft - PHP Simple Member System</title> </head> <body> <center> <font face="Verdana" size="3"><B> Uzzi Soft - PHP Simple Member System Installation </B> </font> <BR><BR> <font face="Verdana" size="2"> We will be installing the PHP Simple Member System into your MySQL Server<BR> Please enter the details of your MySQL Server below.<BR> If you MySQL is located on this computer enter "localhost" without the quotes<BR> in the IP Address of MySQL Server.<BR><BR> This script will create a new database called phpsms and two tables which are<BR> userdata and usersonline<BR><BR><BR> </font> </center> <form action="install.php" method="POST"> <table border="0" width="455" id="table1"> <tr> <td width="273" height="24"><font face="Verdana">IP Address of MySQL Server:</font></td> <td height="24"> <input type="text" name="ipaddressofmysqlserver"/></td> </tr> <tr> <td width="273" height="24"><font face="Verdana">MySQL Username:</font></td> <td height="24"> <input type="text" name="mysqlusername" /></td> </tr> <tr> <td width="273"><font face="Verdana">MySQL Password:</font></td> <td> <input type="password" name="mysqlpassword" /></td> </tr> <tr> <td width="273" height="68"> </td> <td height="68"> <input type="submit" value="Install"> <input type="reset" value="Clear"></td> </tr> </table> </form> <BR><BR> <?php // Begin Installatin of PHP Simple Member System // Variables that data come from the submission form $ipmysql = $_POST["ipaddressofmysqlserver"]; // Ip Address of MySQL Server $mysqlusername = $_POST["mysqlusername"]; // Username of the MySQL Server $mysqlpassword = $_POST["mysqlpassword"]; // Password of the MySQL Server // Check if all the fields are filled in if ((!$ipmysql) || (!$mysqlusername) || (!$mysqlpassword)) { if (!$ipmysql) { echo "Please enter the IP Address of the MySQL Server<BR>"; } if (!$mysqlusername) { echo "Please enter the username of the MySQL Server<BR>"; } if (!$mysqlpassword) { echo "Please enter the password of the MySQL Server<BR>"; } exit(); // If there are errors then we quit this script } // Connect to the MySQL server $link = mysql_connect("$ipmysql", "$mysqlusername", "$mysqlpassword"); // Create a new database mysql_query('CREATE DATABASE phpsms'); // Select the new database mysql_query('USE phpsms'); // Create new userdata table mysql_query('CREATE TABLE userdata (userid VARCHAR(100), userpass VARCHAR(100), name VARCHAR(70), address VARCHAR(50), suburb VARCHAR(50), state VARCHAR(50), postcode VARCHAR(6), phone1 VARCHAR(11), phone2 VARCHAR(11), emailaddress VARCHAR(90), joineddate VARCHAR(19), ip VARCHAR(16), userno INT(11), username VARCHAR(20))'); // Create new usersonline table mysql_query('CREATE TABLE usersonline (username VARCHAR(20))'); // Check is there is both tables and then installation is completed $tablecheckuserdata = mysql_query('SELECT * FROM userdata'); $tablecheckuserdata1 = mysql_num_rows($tablecheckuserdata); $tablecheckusersonline = mysql_query('SELECT * FROM usersonline'); $tablecheckusersonline1 = mysql_num_rows($tablecheckusersonline); if ($tablecheckuserdata1 >= 0 && $tablecheckusersonline >= 0) { echo "Installation Complete!"; mysql_close(); // Close the connection to the MySQL Server } else { echo "A error occured, try again"; exit(); } ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
monk.e.boy Posted March 1, 2007 Share Posted March 1, 2007 Man. You could have errors anywhere. Are you sure you are connected to the DB? Do you have permission to create tables on the DB? Are the tables already created (have you run this script a few times?) Try downloading SQLog and having a look round the DB. Infact, just use SQLog to create the tables, you only ever create the once anyway. monk.e.boy Quote Link to comment Share on other sites More sharing options...
simcoweb Posted March 1, 2007 Share Posted March 1, 2007 Well, here's my guess. It's trying to validate that those tables were created. However, it's using mysql_num_rows which would count the number of entries or records (rows) in the table. Since there's no data then there's no rows. Therefore the query is failing since it's asking if the >= (greater than) 0 which it's not because there's no one in there yet. Just my guess Quote Link to comment Share on other sites More sharing options...
Snooble Posted March 1, 2007 Share Posted March 1, 2007 i think simoco is right. you could insert something into the table. See if it works then. (It can always be deleted) Snooble Quote Link to comment Share on other sites More sharing options...
simcoweb Posted March 1, 2007 Share Posted March 1, 2007 On a second look, my guess is probably wrong since further down it's referring to >= which is greater than or equal to 0. But, the error comes when it's trying to set the value of the variable with the mysql_num_rows function. So, the fact that the table is empty shouldn't produce the error. It's something in the line that's setting the variable. Quote Link to comment Share on other sites More sharing options...
tkolbeck Posted March 1, 2007 Author Share Posted March 1, 2007 could someone make the code that I need in sql to just insert into mysql database so it makes the tables automatically; that i need. I hope that makes sense? :-\ Quote Link to comment Share on other sites More sharing options...
tkolbeck Posted March 1, 2007 Author Share Posted March 1, 2007 does anybody know of a good simple member system that i could use that you know works?? ??? Quote Link to comment Share on other sites More sharing options...
Adika Posted March 1, 2007 Share Posted March 1, 2007 Sure! The best good simple member script is what you create by yourself! PHP is easy language. Just sit down, and you can create a good simple member script in about a month or two. It will be your product, and if there will be errors, you will know how to solve them, because it's your product. To say the truth, I never use ready made scripts. I create everything myself. I hope you will find a script you like somewhere on the web! Adika P.S.: Go to GOOGLE and search there. Quote Link to comment Share on other sites More sharing options...
monk.e.boy Posted March 2, 2007 Share Posted March 2, 2007 To say the truth, I never use ready made scripts. I create everything myself. Ouch! Please take a look at PHP PEAR. Don't waste time reinventing the wheel. monk.e.boy Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.