My code does not produce any error messages. I have 3 files: share.html where the user inputs data into a simple html form, insert.php which says Thank you, $Name then has the code that is supposed to insert the user's input into the database, favorites.php which uses a while loop to display the data from the database. After being thanked the user clicks a link going to favorites.php. The display works fine and will display data I input in PHPMyAdmin. Also I checked and if I put an invalid database name in insert.php it produces the string I wrote for or die. Also input from the form does appear on the insert.php page if I just use REQUEST but that's as far as it goes. Buteven though the correct database name produces no error the input from the html form is not inserted into the database and does not appear on the display page.
Comments:
Jan 18, 2009
- Greetings,
Thanks for your response. I think we may be closer to a solution but I still need help on how to get there. This is the error message produced after I added the code you provided:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/river/public_html/conraise/insert.php on line 17
and this is the line it is referring to:
16 $query="INSERT INTO Main VALUES
17 ('', '$Namefield','$Classfield','$Whyfield')";
18 echo "SQL ==>" STARTOFSQL<br>".$query." ENDOFSQL<br>";
19 mysql_query ($query);
For the life of me I do not see why or where it would be expecting a comma or seni colon there.
Jan 19, 2009
- I tried it but it didn't make the code pass the info to the database. Thanks
Make sure you are connecting to the database,then just before you call your sql to insert use an echo statement to display the sql and check it for syntax:-
$sql = 'insert into table1 values('.$no.','.$no.',"block","'.$value3.'", "'.$value4.'")'; echo "SQL ==>" STARTOFSQL<br>".$sql." ENDOFSQL<br>";
Comments:
Jan 18, 2009
- I always use single quotes around the outside and double quotes around each field string, so try this
$query='INSERT INTO Main VALUES ("", "'.$Namefield.'","'.$Classfield.'","'.$Whyfield."')';
I enclose each field around a pair of double quotes so if $Namefield has a value red it changes to "red" in the insert statement,
so each '". is a double quote, single quote, then fullstop
and ."' is a fullstop, single quote, double quote
years of unix coding makes understanding quotes essential
let me know if you understand, ta HPC
I want to execute java command for a software which is stored on my web server with the help of...
(More)
I want to execute java command for a software which is stored on my web server with the help of command line but this should be executed through php... I have a code as follows,but its not working ,i need to integrate all exec commands. $cmd='cd C:Program FilesApache GroupApache2htdocsmainsphinxsphinx4-1.0beta-binsphinx4-1.0betain'; exec('C:WINNTsystem32cmd.exe'); exec($cmd); exec("java -mx312m -jar wav2text.jar voice_rec.wav>6.txt"); Reply fast>.
Hi there, I am using PHP5, where i need to mail with attachement. exact thing is, am getting the...
(More)
Hi there, I am using PHP5, where i need to mail with attachement. exact thing is, am getting the file in one page through basic input tag with file attribute. in next page am not getting the file path in order to mail it. Please help me.