Including my sql connection

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
YoussefSiblini
Forum Contributor
Posts: 206
Joined: Thu Jul 21, 2011 1:51 pm

Including my sql connection

Post by YoussefSiblini »

Hi Guys ,
I am trying to insert data into 2 databases, what I am using is:

Code: Select all

//insert into the ALL database
include_once "includes/ALL.php";
$addsql = mysql_query("INSERT INTO $Category (UserName, firstname, lastname) VALUES ('$UserName','$first_name','$last_name')");
			
//Include Second Database and insert into it
include_once "includes/Stored.php";
$addsql = mysql_query("INSERT INTO  $Category (UserName, firstname, lastname) VALUES ('$UserName','$first_name','$last_name')");
But this code is not working?

Youssef
YoussefSiblini
Forum Contributor
Posts: 206
Joined: Thu Jul 21, 2011 1:51 pm

Re: Including my sql connection

Post by YoussefSiblini »

mm I think I am adding more characters to the text field in the database, do any one have an idea how many characters am i allowed to enter into a text field in the database?
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: Including my sql connection

Post by twinedev »

Execute the following query:

DESCRIBE `table_name`;
YoussefSiblini
Forum Contributor
Posts: 206
Joined: Thu Jul 21, 2011 1:51 pm

Re: Including my sql connection

Post by YoussefSiblini »

sorry but what does that do?
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: Including my sql connection

Post by twinedev »

It describes the table, including the size or varchars so you know how many characters you can put into it.

-Greg
YoussefSiblini
Forum Contributor
Posts: 206
Joined: Thu Jul 21, 2011 1:51 pm

Re: Including my sql connection

Post by YoussefSiblini »

Thank you,
I am not sure if this problem I am having is from this but I will give you an idea,
First this error happen only if the user put lots of text, and it work fine if he input a few amount of text.
I got a text area in my page user input in that area then when the user press the button that value stored in a temporary table (which works fine), when I try to copy the data from this temporary table into the actual table it does not copy them (as mentioned only if the user input a big amount of characters in the text area).

Here is the info:

Temporary table

Code: Select all


	#	Column	Type	Collation	Attributes	Null	Default	Extra	Action
	 1	id	int(11)			No	None	AUTO_INCREMENT	  Change	  Drop	 More 
	 2	track_ID	varchar(255)	latin1_swedish_ci		Yes	NULL		  Change	  Drop	 More 
	 3	UserName	varchar(200)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 4	firstname	varchar(200)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 5	lastname	varchar(200)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 6	producttittle	varchar(200)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 7	productdescription	text	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 8	swaptakeplace	varchar(30)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 9	ExchangeWithTittle	varchar(200)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 10	ExchangeWithDescription	text	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 11	shippingfirstname	varchar(200)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 12	shippinglastname	varchar(200)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 13	address1	varchar(200)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 14	address2	varchar(200)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 15	city	varchar(100)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 16	country	varchar(100)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 17	postalcode	varchar(100)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 18	phonenumber	varchar(100)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 19	email	varchar(150)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 20	Category	varchar(255)	latin1_swedish_ci		Yes	NULL		  Change	  Drop	 More 
	 21	IpAddress	varchar(200)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 22	dateadded	date			No	None		  Change	  Drop	 More 
The actual table

Code: Select all

	#	Column	Type	Collation	Attributes	Null	Default	Extra	Action
	 1	id	int(11)			No	None	AUTO_INCREMENT	  Change	  Drop	 More 
	 2	track_ID	varchar(255)	latin1_swedish_ci		Yes	NULL		  Change	  Drop	 More 
	 3	UserName	varchar(200)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 4	firstname	varchar(200)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 5	lastname	varchar(200)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 6	producttittle	varchar(200)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 7	productdescription	text	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 8	swaptakeplace	varchar(30)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 9	ExchangeWithTittle	varchar(200)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 10	ExchangeWithDescription	text	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 11	shippingfirstname	varchar(200)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 12	shippinglastname	varchar(200)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 13	address1	varchar(200)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 14	address2	varchar(200)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 15	city	varchar(100)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 16	country	varchar(100)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 17	postalcode	varchar(100)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 18	phonenumber	varchar(100)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 19	email	varchar(150)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 20	Category	varchar(255)	latin1_swedish_ci		Yes	NULL		  Change	  Drop	 More 
	 21	IpAddress	varchar(200)	latin1_swedish_ci		No	None		  Change	  Drop	 More 
	 22	dateadded	date			No	None		  Change	  Drop	 More 

Youssef
YoussefSiblini
Forum Contributor
Posts: 206
Joined: Thu Jul 21, 2011 1:51 pm

Re: Including my sql connection

Post by YoussefSiblini »

I am using this to get the info from the temporary table and add them to the actual table:

Code: Select all

   
      // get the information from the unpaid table
      $sql = mysql_query("SELECT * FROM temporary WHERE track_ID='$track_ID' LIMIT 1");
      $productCount = mysql_num_rows($sql); // count the output amount
      if ($productCount > 0) 
	  {
	       while($row = mysql_fetch_array($sql))
		   { 
		     // get the information from notpaid table
			 $id = $row["id"];
			 $UserName = $row["UserName"];
			 $firstname = $row["firstname"];
			 $lastname = $row["lastname"];
			 $producttittle = $row["producttittle"];
			 $productdescription = $row["productdescription"];
			 $swaptakeplace = $row["swaptakeplace"];
			 $ExchangeWithTittle = $row["ExchangeWithTittle"];
			 $ExchangeWithDescription = $row["ExchangeWithDescription"];
			 $shippingfirstname = $row["shippingfirstname"];
			 $shippinglastname = $row["shippinglastname"];
			 $address1 = $row["address1"];
			 $address2 = $row["address2"];
			 $city = $row["city"];
			 $country = $row["country"];
			 $postalcode = $row["postalcode"];
			 $phonenumber = $row["phonenumber"];
			 $Category = $row["Category"];
			 $email = $row["email"];
			 $ipaddress = $row["IpAddress"];
			 			 
			 
			 // Add the exchange into the specified table
			 $addsql = mysql_query("INSERT INTO $Category (track_ID, UserName, firstname, lastname, producttittle, productdescription, swaptakeplace ,ExchangeWithTittle,ExchangeWithDescription, shippingfirstname, shippinglastname, address1, address2, city, country, postalcode, phonenumber, email, Category,  IpAddress, dateadded) VALUES ('$track_ID','$UserName','$first_name','$last_name','$producttittle','$productdescription', '$swaptakeplace' ,'$ExchangeWithTittle','$ExchangeWithDescription','$shippingfirstname','$shippinglastname','$address1','$address2','$city','$country','$postalcode','$phonenumber','$email','$Category','$ipaddress',now())");

		   } 
	  }
Post Reply