help

4 posts Page 1 of 1
Contributors
User avatar
Shim
VIP - Donator
VIP - Donator
Posts: 882
Joined: Wed Dec 14, 2011 5:02 am

help
Shim
help with this import tables code!
Code: Select all

<?
include "./config.php";

if ($create){
	include "./mysql.php";
	$sql = "CREATE TABLE $adstable (
	  id int(15) NOT NULL auto_increment,
	  keyword varchar(255) NOT NULL default '',
	  ad varchar(255) NOT NULL default '',
	  url varchar(255) NOT NULL default '',
	  clicks int(15) NOT NULL default '0',
	  impressions int(15) NOT NULL default '0',
	  PRIMARY KEY  (id)
	) TYPE=MyISAM;";
	$result = mysql_query($sql) or die("Failed: $sql");

	$sql = "CREATE TABLE $table (
	  id int(11) NOT NULL auto_increment,
	  url varchar(255) NOT NULL default '0',
	  title varchar(255) NOT NULL default '0',
	  descr varchar(255) NOT NULL default '0',
	  clicks int(11) NOT NULL default '0',
	  dateentered datetime NOT NULL default '0000-00-00 00:00:00',
	  PRIMARY KEY  (id),
	  UNIQUE KEY url (url)
	) TYPE=MyISAM;";
	$result = mysql_query($sql) or die("Failed: $sql");

	$sql = "CREATE TABLE $enginestable (
	  engorder int(5) NOT NULL default '0',
	  engine varchar(255) NOT NULL default '',
	  cache int(1) NOT NULL default '0'
	) TYPE=MyISAM;";
	$result = mysql_query($sql) or die("Failed: $sql");
	$sql = "insert into $enginestable values('1', 'dmoz', '1')";
	$result = mysql_query($sql);
	$sql = "insert into $enginestable values('2', 'msn', '1')";
	$result = mysql_query($sql);

	print "The MySQL tables <b>$table</b>, <b>$adstable</b>, and <b>$enginestable</b> have been created and are ready for use! I highly suggest that you now delete <b>create_tables.php</b> before you continue.";
	exit;
}
?>

<p>This script will automatically create the MySQL tables for your search engine. 
  You MUST edit config.php before this script can be run. The 'Create Tables' 
  button will appear below if you've successfully given all the info needed to 
  do this. Please review the info below just to be sure:</p>
<p>Database Host: <? print $sqlhost; ?><br>
  Database Login: <? print $sqllogin; ?><br>
  Database Password: <? print $sqlpass; ?><br>
  Database Name: <? print $sqldb; ?><br>
  Websites Table: <? print $table; ?><br>
  Advertisements Table: <? print $adstable; ?><br>
  Meta Engines Table: <? print $enginestable; ?><br>
  <br>
  If this is all correct, click the 'Create Table' button below. If the button 
  does not show below, it's because one of these fields are empty.</p>
<?
if ($sqlhost && $sqllogin && $sqldb && $table && $adstable && $enginestable) print "<form name='form1' method='post' action='create_tables.php'>
  <div align='center'>
    <input type='hidden' name='create' value='1'>
    <input type='submit' value='Create Tables!'>
  </div>
</form>";
?>
Find my programs on Softpedia
User avatar
benji_19994
VIP - Donator
VIP - Donator
Posts: 156
Joined: Mon Apr 16, 2012 3:13 pm

Re: help
benji_19994
Are You getting any error's if so it would help to find out your problem.
User avatar
Shim
VIP - Donator
VIP - Donator
Posts: 882
Joined: Wed Dec 14, 2011 5:02 am

Re: help
Shim
it isnt importing into my sql that is p-roblem
Find my programs on Softpedia
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

Re: help
Scottie1972
each of your "$result" and "$sql" must have a different name.
ei: $result0, $result1, $result2 and $sql0, $sql1, $sql2

all you are doing is confusing the php engine.

this is how i do it.
'CREATE
Code: Select all
<?php
// Make a MySQL Connection
mysql_connect("localhost", "admin", "1admin") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());

// Create a MySQL table in the selected database
mysql_query("CREATE TABLE example(
id INT NOT NULL AUTO_INCREMENT, 
PRIMARY KEY(id),
 name VARCHAR(30), 
 age INT)")
 or die(mysql_error());  

echo "Table Created!";

?>
'INSERT
Code: Select all
<?php
// Make a MySQL Connection
mysql_connect("localhost", "admin", "1admin") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());

// Insert a row of information into the table "example"
mysql_query("INSERT INTO example 
(name, age) VALUES('Timmy Mellowman', '23' ) ") 
or die(mysql_error());  

mysql_query("INSERT INTO example 
(name, age) VALUES('Sandy Smith', '21' ) ") 
or die(mysql_error());  

mysql_query("INSERT INTO example 
(name, age) VALUES('Bobby Wallace', '15' ) ") 
or die(mysql_error());  

echo "Data Inserted!";

?>
you really need to study the tuts here ( http://www.tizag.com/mysqlTutorial/index.php )
Image
4 posts Page 1 of 1
Return to “Help & Support”