Link to home
Create AccountLog in
Avatar of mgtm3
mgtm3Flag for Israel

asked on

why i cant insert into a field in a table in mysql things like "." "?" "," ?????

i have a field in a table and i want to insert in it this symbols
?
.
,
'
but its not working
why is that?
ASKER CERTIFIED SOLUTION
Avatar of vibrazy
vibrazy
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of mgtm3

ASKER

look att the code and tell me what to do?
<?php
 
include 'cpoll.php';
 
 
$subject = $_POST['subject'];
$op1 = $_POST['op1'];
$op2 = $_POST['op2'];
$op3 = $_POST['op3'];
$op4 = $_POST['op4'];
$op5 = $_POST['op5'];
$op6 = $_POST['op6'];
$op7 = $_POST['op7'];
$op8 = $_POST['op8'];
$op9 = $_POST['op9'];
$op10 = $_POST['op10'];
$op11 = $_POST['op11'];
$op12 = $_POST['op12'];
$gen=$_POST['gen'];
 
 
$result = mysqli_query($link, "SELECT count(*) FROM $gen");
$row = mysqli_fetch_array($result, MYSQLI_NUM);
$row[0]++;
$pollname="poll".$gen.$row[0];
echo $pollname; 
 
 
 
echo "subject - ".$subject."<br />op1 - ".$op1."<br />op2 - ".$op2."<br />op3 - ".$op3."<br />op4 - ".$op4."<br />op5 - ".$op5."<br />gen - ".$gen;
 
$sql = "CREATE TABLE $pollname (
`id` int( 255 ) NOT NULL AUTO_INCREMENT,
  `subject` VARCHAR( 700 )NOT NULL,
        `op1` VARCHAR( 700 )NOT NULL,
        `op2` VARCHAR( 700 ) NOT NULL,
        `op3` VARCHAR( 700 ) NOT NULL,
        `op4` VARCHAR( 700 ) NOT NULL,
        `op5` VARCHAR( 700 ) NOT NULL,
		 `op6` VARCHAR( 700 )NOT NULL,
        `op7` VARCHAR( 700 ) NOT NULL,
        `op8` VARCHAR( 700 ) NOT NULL,
        `op9` VARCHAR( 700 ) NOT NULL,
        `op10` VARCHAR( 700 ) NOT NULL,
		`op11` VARCHAR( 700 ) NOT NULL,
        `op12` VARCHAR( 700 ) NOT NULL,
            `date` VARCHAR( 700 ) NOT NULL,
            `user` VARCHAR( 700 ) NOT NULL,
			            `comment` text NOT NULL,
 
            `gen` VARCHAR( 700 ) NOT NULL,
            
        PRIMARY  KEY ( `id` )
       )";
 
 
 
 
 
mysqli_query($link,$sql);
 
mysqli_close($link);
unset($link);
include 'cpoll.php';
 
$f = "INSERT INTO $pollname (op1,op2,op3,op4,op5,subject,gen) VALUES ('$op1','$op2','$op3','$op4','$op5','$subject','$gen')"; 

Open in new window

Try this, if that doesnt work, tell me what error you are getting.

Regards,
Vibrazy
$f = "INSERT INTO $pollname (op1,op2,op3,op4,op5,subject,gen) VALUES ('".$op1."','".$op2."','".$op3."','".$op4."','".$op5."','".$subject."','".$gen."')"; 
mysqli_query($link,$f);

Open in new window

Avatar of mgtm3

ASKER

can u write me the function to get the error ?
Avatar of mgtm3

ASKER

o.k this what i got

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's Day','Valentine's Day','Favorite holiday?','other')' at line 1
SOLUTION
Avatar of gamebits
gamebits
Flag of Canada image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of mgtm3

ASKER

thanksssssssssssssssss
Avatar of afzz
afzz

You can also do the following instead of individually changing the values
foreach($_POST as $key => $val){
${$key} = mysql_real_escape_string($val);
}

Open in new window