laxi Posted September 23, 2013 Share Posted September 23, 2013 Hello , can some one breakdown and explain the below syntax $sql = "INSERT INTO tutorials_tbl ". "(tutorial_title,tutorial_author, submission_date) ". "VALUES ". "('$tutorial_title','$tutorial_author','$submission_date')"; $sql = "CREATE TABLE tutorials_tbl( ". "tutorial_id INT NOT NULL AUTO_INCREMENT, ". "tutorial_title VARCHAR(100) NOT NULL, ". "tutorial_author VARCHAR(40) NOT NULL, ". "submission_date DATE, ". "PRIMARY KEY ( tutorial_id )); "; the . and " are confusing.. Quote Link to comment https://forums.phpfreaks.com/topic/282375-need-an-understanding-on-this-syntax/ Share on other sites More sharing options...
Solution cyberRobot Posted September 23, 2013 Solution Share Posted September 23, 2013 For whatever reason the SQL query is just broken into multiple string and connected with the concatenation operator: http://php.net/manual/en/language.operators.string.php To simplify the first query, it could be written as: <?php $sql = "INSERT INTO tutorials_tbl (tutorial_title,tutorial_author, submission_date) VALUES ('$tutorial_title','$tutorial_author','$submission_date')"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/282375-need-an-understanding-on-this-syntax/#findComment-1450805 Share on other sites More sharing options...
Ch0cu3r Posted September 23, 2013 Share Posted September 23, 2013 The two lines of code is assigning a SQL (cee-qual) command to a variable named $sql. Strings are contained within quotes. The dot (.) is the concatenation operator. This operator joins two strings together example $var1 = 'hello'; $var2 = ' world'; echo $var1 . $var2; The above will output the text hello world Quote Link to comment https://forums.phpfreaks.com/topic/282375-need-an-understanding-on-this-syntax/#findComment-1450806 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.