lilyyan
asked on
is there a syntax error in my php sql statement
hello:
i'm using the follwoing code insert data to a table. i'm using odbc connection in ms sql 2005
but the insert statement is failed to exected.
the error is : SQL state 00000 in SQLExecDirect in line : odbc_exec($dbconnect, $SQL);
i tried both
odbc_execute ($query, $parameters);
odbc_exec($dbconnect, $SQL);
it's just not working...
could some expert here help me? thank you so much !
i'm using the follwoing code insert data to a table. i'm using odbc connection in ms sql 2005
but the insert statement is failed to exected.
the error is : SQL state 00000 in SQLExecDirect in line : odbc_exec($dbconnect, $SQL);
i tried both
odbc_execute ($query, $parameters);
odbc_exec($dbconnect, $SQL);
it's just not working...
could some expert here help me? thank you so much !
$SQL = "INSERT INTO myProject (Project_Title, Time_Location_Group, Subject_Area, Professor_Name,
Professor_Email,Project_Description, Student_Qualifications, Hours, Credits,
Credit_Hours, Status, Affiliation_Centers, Project_Links, Entry_Date) VALUES
('{$projtitle}','{$projlocation}','{$subjectarea}','{$profname}',
'{$email}', '{$projdesc}','{$quals}','{$hours}','{$credits}','{$credithours}',
'{$status}','{$DPs}','{$websites}', '{$date}')";
/*$parameters = array($projtitle,$projlocation,$subjectarea,$profname,
$email, $projdesc,$quals,$hours,$credits,$credithours,
$status,$DPs,$websites, $date);
$query=odbc_prepare($dbconnect, $SQL);
odbc_execute ($query, $parameters); */
odbc_exec($dbconnect, $SQL);
odbc_close($dbconnect);
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
OK, then the other question is, are actually connecting to the db? I don't see where you are setting the $dbconnect variable.
ASKER
thank you for your reply!
about apostrophe sign, should i strip of magic_quotes_gpc and then use str_replace("'","''",$proj title). ?
the connection is like the following.
about apostrophe sign, should i strip of magic_quotes_gpc and then use str_replace("'","''",$proj
the connection is like the following.
<?php
//Set up Variables
//connect to MS SQL 2005 Dev
$dbHost = "hostServer";
$dbUser = 'clientUser';
$dbPass = 'myPass';
$dsn= 'myDataSource'; //datasources
// Open DB connection
$dbconnect =odbc_connect($dsn, $dbUser, $dbPass, SQL_CUR_USE_ODBC)
or DIE ("DATABASE FAILED TO RESPOND.");
?>
ASKER
myhost server has turned the magic_quotes_gpc, so by default, apostrophe will be escaped as \'
so i don't think i should use : str_replace("'","''",$proj
am i right? thank you so much !!