0

Whilst working on my first MYSQL, i came accross this error, and even with a friend who is a pretty good coder and we couldn't work it out

<?php
$con=mysql_connect("mysql3.000webhost.com","a2778852_556875", "pendolino390");

//CREATE DATABASE
	mysql_create_db("personal_experience", $con);
			 
	//CREATE TABLE 
	$con=mysql_select_db('Personal_experiences',$con);
	
	if($con) {
	$sql="CREATE DATABASE personal_ex
		(
			Additioncode int NOT NULL AUTO_INCREMENT,
			PRIMARY KEY(Additioncode),
			Personalexperiences text,
			Sex tinyint,
			Age int,
			Sexuality tinyint,
		)";
		
		mysql_query($sql,$con);
		$sql="insert into personal_ex(Personalexperience,Sex,Age,Sexuality) values ('$post[Personalexperience]','$post[Sex],$post[Age]','$post[Sexuality]')";

//insert record	
mysql_query($sql,$con); 
        echo "Added to records";
        mysql_close($con);
?>

Can anyone here help me?

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by ko ko
0

Missing single quotes on line 22.

Changed it to single quotes then gave me an "T_VARIABLE" error

1

$sql="insert into personal_ex(Personalexperience,Sex,Age,Sexuality) values ('$post[Personalexperience]','$post[Sex],$post[Age]','$post[Sexuality]')";

What is the '$post[]' ? Is it the php array or the HTTP_POST_VAR ? The correct use of the HTTP_POST_VAR is '$_POST' or '$_REQUEST'.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.