473,507 Members | 2,447 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

error, unexpected T_STRING in

24 New Member
Hi
I will like to add this below code to my data base but I have a string error that I cant correct be for I put it in my db can you pleas help

I cant find any thing wrong with this line but it tels me that I have a "unexpected T_STRING" error in line 11 that is the line starting with "CREATE TABLE `course` and I sagest if this one line gives me a string error the rest of the lines will give me a error to be cos it all looks the same ore wont that matter


Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. CREATE TABLE `course` 
  4. (
  5. `cname` varchar(50) NOT NULL default",
  6. `cid` int(6) NOT NULL auto_increment,
  7. PRIMARY KEY (`cid`)
  8. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  9.  
  10.  
  11. CREATE TABLE `course_student`(
  12. `sno` int(6) NOT NULL default '0',
  13. `cid` int(6) NOT NULL default '0',
  14. `year` int(4) NOT NULL default '0'
  15. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  16.  
  17.  
  18. CREATE TABLE `student`(
  19. `sno` int(6) NOT NULL auto_increment,
  20. `sname` varchar(40) NOT NULL default",
  21. `init` varchar(5) NOT NULL default",
  22. `fname` varchar(40) NOT NULL default",
  23. `title` varchar(4) NOT NULL default",
  24. `msname` varchar(40) NOT NULL default",
  25. `dob` varchar(8) NOT NULL default",
  26. `sex` char(2) NOT NULL default",
  27. `lang` varchar(10) NOT NULL default",
  28. `idno` varchar(13) NOT NULL default",
  29. `telh` varchar(12) NOT NULL default",
  30. `telw` varchar(12) NOT NULL default",
  31. `cel` varchar(12) NOT NULL default",
  32. `fax` varchar(12) NOT NULL default",
  33. `email` varchar(40) NOT NULL default",
  34. `address` tinytext NOT NULL,
  35. PRIMARY KEY (`sno`)
  36. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  37.  
  38. ?>
  39.  
Thanks
May 10 '10 #1
7 1903
Dormilich
8,658 Recognized Expert Moderator Expert
strings have to be wrapped in " or '.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $sql1 = "CREATE TABLE `course` 
  3. (
  4. `cname` varchar(50) NOT NULL default,
  5. `cid` int(6) NOT NULL auto_increment,
  6. PRIMARY KEY (`cid`)
  7. ENGINE=MyISAM DEFAULT CHARSET=latin1";
May 10 '10 #2
Markus
6,050 Recognized Expert Expert
That simply ain't valid PHP. What's the usefulness of sticking a load of SQL into a PHP file?
May 10 '10 #3
shanehenery
24 New Member
HI
if that is all I need to do it is still no working
now it gives me a error unexpected , in line 20
Expand|Select|Wrap|Line Numbers
  1. `sname` varchar(40) NOT NULL default", 
May 11 '10 #4
Markus
6,050 Recognized Expert Expert
You need to escape that quote with a backslash.
May 11 '10 #5
dlite922
1,584 Recognized Expert Top Contributor
How are those SQL codes going to "magically" get added to your database?

Looks like somebody needs a tutorial:
http://w3schools.com/php/php_mysql_intro.asp




Dan
May 11 '10 #6
shanehenery
24 New Member
HI
it is just an example ones there is no error on the script I will add it to my db
but my db don't want to accept the code be cos there is a error
May 12 '10 #7
Dormilich
8,658 Recognized Expert Moderator Expert
what you have shown here is just plain SQL code. there’s much more required to make a database script.
May 12 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2873
by: Salim | last post by:
Hi people, keep getting this errorParse error: parse error, unexpected T_STRING in order_fns.php line 91. the code is below for the file and I've indicated line 91 <?php function...
4
22129
kestrel
by: kestrel | last post by:
I have some html code that is supposed to be displayed by php echo. But for some reason i keep getting a syntax error, and i cant figure out what is going on. Heres what i have <?php...
6
2602
by: goodguyjam | last post by:
Hi all, I'm having trouble with mysql. I've just finished my php coding for HTTP authentication and with some help am now getting a login window pop up whenever I click on a link on my website...
21
8510
by: Jordan79 | last post by:
I have uploaded a file and am now trying to store it in a DB. I am getting a "Parse error: syntax error, unexpected T_STRING" error on this line below: INSERT INTO gallery (user_id, image_name) ...
3
2384
by: sclarkstone | last post by:
Im getting this error; Parse error: syntax error, unexpected T_STRING, expecting ':' or ';' with this line; header ('postcodesearch.php?e=nw&pcode=',); I cant find whats wrong, can anyone...
3
5583
paulrajj
by: paulrajj | last post by:
hi to all, i am getting syntax error on my code.. Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in D:\xampp\htdocs\Dummy\paulraj\matrim\exam.php on line 62 ...
11
2904
by: JRough | last post by:
I'm trying to use output buffering to cheat so i can print to excel which is called later than this header(). header("Content-type: application/xmsdownload"); header("Content-Disposition:...
0
1792
by: JRough | last post by:
On Sep 26, 3:23 pm, Captain Paralytic <paul_laut...@yahoo.comwrote: without the exit I get this again: Warning: Cannot modify header information - headers already sent by (output started at...
10
5623
by: benicio | last post by:
Parse error: syntax error, unexpected T_STRING, expecting '(' in C:\wamp\www\study_group\includes\functions.php on line 19 I got this error and this syntax is from 8 to 19th line. <?php ...
14
5484
riverdale1567
by: riverdale1567 | last post by:
Hi I am a newbie trying to get some of my first code working, yada yada yada. I have a drop down box which chooses a state then takes the post data to 'processform2.php' to use that to pull up...
0
7221
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7109
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7029
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5039
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3190
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.