Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,462 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,358 people online right now. Registration is fast and FREE... Join Now!




Query

2 Pages V  1 2 >  
Reply to this topicStart new topic

Query, simplequiz

SpaceMan
post 19 Mar, 2005 - 12:25 AM
Post #1


D.I.C Regular

Group Icon
Joined: 20 Feb, 2003
Posts: 270

was trying to make auto databse installer for robets quiz. seems i missing something

$dbHost="localhost";
$dbUser="root";
$dbPass="";
$dbase = "simplequiz";
$mysqlcon = mysql_connect("$dbHost", "$dbUser", "$dbPass") or die ("".mysql_error()."");
mysql_select_db("$dbase", $mysqlcon) or die ("".mysql_error()."");

function mysql_table_exists($table){
$exists = @mysql_query("SELECT 1 FROM `$table` LIMIT 0", $mysqlcon);
if ($exists) return true;
return false;
}
if (mysql_table_exists("answer")==false){
global $mysqlcon;
$this_file = fopen("simplequiz.sql", "r");
$loadcontent = fread($this_file, filesize("simplequiz.sql"));
$lines = explode("\n", $loadcontent);
$line[] = explode("\n", $loadcontent);
$count = count($lines);
@fclose($this_file);
for ($a = 1; $a < $count; $a++) {
$query = $lines[$a];
echo $query;
}
mysql_db_query($query, $mysqlcon);

}
User is offlineProfile CardPM

Go to the top of the page

cyberscribe
post 19 Mar, 2005 - 12:32 AM
Post #2


humble.genius

Group Icon
Joined: 5 May, 2002
Posts: 1,062



Thanked 2 times

Dream Kudos: 154
My Contributions


Are you getting an error message?
User is offlineProfile CardPM

Go to the top of the page

SpaceMan
post 19 Mar, 2005 - 12:33 AM
Post #3


D.I.C Regular

Group Icon
Joined: 20 Feb, 2003
Posts: 270

QUOTE(cyberscribe @ Mar 19 2005, 01:32 AM)
Are you getting an error message?

no
echo is printing the file, but not created in DB.
User is offlineProfile CardPM

Go to the top of the page

cyberscribe
post 19 Mar, 2005 - 12:37 AM
Post #4


humble.genius

Group Icon
Joined: 5 May, 2002
Posts: 1,062



Thanked 2 times

Dream Kudos: 154
My Contributions


Each query ends in a semicolon. Split that file by semicolons and run one query for each. You should have better luck.
User is offlineProfile CardPM

Go to the top of the page

SpaceMan
post 19 Mar, 2005 - 12:45 AM
Post #5


D.I.C Regular

Group Icon
Joined: 20 Feb, 2003
Posts: 270

hmm, tryed that and split #, nothing.
User is offlineProfile CardPM

Go to the top of the page

SpaceMan
post 19 Mar, 2005 - 12:56 AM
Post #6


D.I.C Regular

Group Icon
Joined: 20 Feb, 2003
Posts: 270

tryed different variations of this, says query empty

$query=explode(";",$loadcontent);
for ($a = 1; $a < count($query)-1; $a++) {
mysql_db_query($dbase,$query[$i],$mysqlcon) or die(mysql_error());
}
User is offlineProfile CardPM

Go to the top of the page

SpaceMan
post 19 Mar, 2005 - 02:22 AM
Post #7


D.I.C Regular

Group Icon
Joined: 20 Feb, 2003
Posts: 270

doh, i see what i did, works now.
User is offlineProfile CardPM

Go to the top of the page

SpaceMan
post 19 Mar, 2005 - 02:55 AM
Post #8


D.I.C Regular

Group Icon
Joined: 20 Feb, 2003
Posts: 270

ok, re wrote it a bit,

<?PHP
/** Header File
*
* This file contains constants used elsewhere
* modify the $mysqlcon variable to connect SimpleQuiz
* to your own MySQL database
*
* @package SimpleQuiz
* @author Robert Peake <robert@peakepro.com>
* @copyright &copy; 2004
* @link http://www.simplequiz.com
* @license http://www.gnu.org/licenses/gpl.txt
* @version 1.0
*/
$contact = ""; //fill this in to give out your administrator's contact email address in case of errors
$smartydir = "Smarty-2.6.0/";

$dbHost="localhost";
$dbUser="root";
$dbPass="";
$dbase = "simplequiz";
$mysqlcon = mysql_connect("$dbHost", "$dbUser", "$dbPass") or die ("".mysql_error()."");
mysql_select_db("$dbase", $mysqlcon) or die ("".mysql_error()."");
$dbfile = "simplequiz.sql";
if (!@mysql_query("SELECT 1 FROM `answer` LIMIT 0", $mysqlcon)){
$loadcontent = fread(fopen("$dbfile", "r"), 85760);
$query=explode(";\n",$loadcontent);
for ($a = 1; $a < count($query)-1; $a++) {
mysql_db_query($dbase,$query[$a],$mysqlcon) or die(mysql_error());
}
}

?>
User is offlineProfile CardPM

Go to the top of the page

SpaceMan
post 19 Mar, 2005 - 03:08 AM
Post #9


D.I.C Regular

Group Icon
Joined: 20 Feb, 2003
Posts: 270

seems it thinks it is installed on the http root, could not login.

but changed
$smarty_login->assign('action','".$PHP_SELF."');
User is offlineProfile CardPM

Go to the top of the page

SpaceMan
post 19 Mar, 2005 - 03:13 AM
Post #10


D.I.C Regular

Group Icon
Joined: 20 Feb, 2003
Posts: 270

also apears it uses url rewrite, i not have it on my test puter.
i late, later
User is offlineProfile CardPM

Go to the top of the page

cyberscribe
post 19 Mar, 2005 - 10:39 AM
Post #11


humble.genius

Group Icon
Joined: 5 May, 2002
Posts: 1,062



Thanked 2 times

Dream Kudos: 154
My Contributions


Yeah ... the .htaccess thingies are for Apache to support the url rewriting. I should probably make this optional so that confused Windows uers can still use the package. The URL rewriting isn't really necessary for SEO or anything, just looks nicer IMHO. It's not hard to do -- just replace '/login' calls with '/login.php' calls, etc.
User is offlineProfile CardPM

Go to the top of the page

cyberscribe
post 19 Mar, 2005 - 10:41 AM
Post #12


humble.genius

Group Icon
Joined: 5 May, 2002
Posts: 1,062



Thanked 2 times

Dream Kudos: 154
My Contributions


btw, those of you that wonder what we're talking about:

http://www.simplequiz.com/
User is offlineProfile CardPM

Go to the top of the page

2 Pages V  1 2 >
Fast ReplyReply to this topicStart new topic
Time is now: 11/22/08 01:12PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month