473,569 Members | 2,400 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 1908
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
2879
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 process_card($card_details) { // connect to payment gateway or // use gpg to encrypt and mail or // store in DB if you really want to
4
22136
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 if(isset($_GET)) { echo "<div id="visible">"; echo "<span onclick="swapform()">Log In Form</span>"; echo "</div>"; echo "<div id="theform"...
6
2611
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 that directs to Auth.php. The code for this is below: <?php /* Program: Auth.php * Desc: Program that prompts for a user name and * ...
21
8521
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) VALUES ($RecordsetUserID, UPLOAD_DIR.$_SESSION.'/'.$now.$_SESSION.'-'.$file); Can anyone help?
3
2390
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 help?
3
5590
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 what's the actual problem here..? my code
11
2918
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: attachment; header("Pragma: no-cache"); header("Expires; 0"); print "$header\n$data";
0
1798
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 /home/allrail/public_html/header.php:40) in /home/ allrail/public_html/header.php on line 39 as well as this: Fatal error: Cannot redeclare maketr()...
10
5635
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 $subject_set = get_all_subjects(); while ($subject = mysql_fetch_array($subject_set)) { echo...
14
5492
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 all the rows which have the corresponding state. I am getting this 'Parse error: syntax error, unexpected T_STRING in /home/attorney/public_html/' on...
0
7703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7679
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6287
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2117
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
946
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.