Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Parse error, unexpected T_STRING????????
Old 05-25-2010, 05:40 PM Parse error, unexpected T_STRING????????
ericson3000's Avatar
Experienced Talker

Posts: 40
Name: Bob Davis
Location: Los Angeles, CA
Trades: 0
Hey guys, I'm getting a Parse error on line 8, but I don't see a problem with my syntax. Any help is much appreciated.

<?php
// this is an actual connect
$dbc = mysqli_connect("whatever.net", "testing", "password", "names") or die("Error connecting to MySQL server."); // assigns a variable name to the connect

// this is the INSERT INTO
$firstName = $_POST["firstName"]; // assigns a variable to the info from form
$lastName = $_POST["lastName"]; // assigns a variable to the info from form
$query = INSERT INTO names (firstname, lastname) VALUES ($firstName, $lastName); // assigns a variable to the INSERT INTO

// this uses the above variables to to the actual connect and INSERT INTO
$result = mysqli_query($dbc, $query) or die("Error querying database."); // issues the INSERT query on the MySQL database

// this closes the connection to the database
mysqli_close($dbc);
?>
ericson3000 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-25-2010, 05:46 PM Re: Parse error, unexpected T_STRING????????
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
$query = 'INSERT INTO names (firstname, lastname) VALUES ($firstName, $lastName)';

Strings need to be enclosed in quotes
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-25-2010, 05:47 PM Re: Parse error, unexpected T_STRING????????
ericson3000's Avatar
Experienced Talker

Posts: 40
Name: Bob Davis
Location: Los Angeles, CA
Trades: 0
Thanks for the quick reply as always chrishirst!
ericson3000 is offline
Reply With Quote
View Public Profile
 
Old 05-26-2010, 02:56 PM Re: Parse error, unexpected T_STRING????????
Extreme Talker

Posts: 181
Name: David Jackson
Trades: 0
are the arguments in the correct order in your

mysqli_query($dbc, $query)
__________________

Please login or register to view this content. Registration is FREE
davidj is offline
Reply With Quote
View Public Profile
 
Old 05-27-2010, 04:16 PM Re: Parse error, unexpected T_STRING????????
Average Talker

Posts: 20
Trades: 0
Also, it's good practice to put your values in quotes too. If they are strings it's required actually lol..
__________________

Please login or register to view this content. Registration is FREE
- Awesome Price, Awesome Support, Awesomely Awesome...


Please login or register to view this content. Registration is FREE
- Web Development, E-Commerce, SEO, SMM, CMS's
holmessph is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Parse error, unexpected T_STRING????????
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.34499 seconds with 12 queries