Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: Script issue
PostPosted: Mon Sep 14, 2009 12:48 pm 
Offline
Senior Newbie
User avatar

Joined: Wed Jun 13, 2007 3:14 am
Posts: 13
Website: http://www.hl2stk.net
AOL: webc0der
Location: Florida
Hey guys,

Hoping someone can help me out. On my linode I have mysql, php & apache, and im trying to write a script to pull info from my database, but I keep getting this error:

Quote:
PHP Parse error: syntax error, unexpected T_LOGICAL_OR in /var/www/vhosts/xxx.net/httpdocs/Tim/dbconnect.php on line 24, referer: http://xxx.net/Tim/Registration.htm


Heres the script:
Code:
<?php
//set database connection variables
$host='localhost';
$dbuser='xxx';
$dbpass='xxx';
$dbname='xxx';

$connection = mysql_connect($host, $dbuser, $dbpass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());

require('dbconnect.php');
if($_POST['submit']) {
$firstname = $_POST['firstname'];
$middlename = $_POST['middlename'];
$lastname = $_POST['lastname'];
$sex = $_POST($sex);
$emailaddress = $_POST['emailaddress'];
if((empty($firstname)) OR (empty($middlename)) OR (empty($lastname)) OR (empty($sex)) OR (empty($sex)))
{
echo "Please fill in all fields!";
}
if (empty($you)) OR (empty($others));
{
echo "Please agree to both terms or you cannot be a member! (All members are bound by these terms and if they violate them their membership will be revoked.)";
}
else {
$query = "INSERT INTO ifdbt0 (memberid, firstname, middlename, lastname, sex, emailaddress) VALUES ('', '$firstname', '$middlename', '$lastname', '$sex', '$emailaddress;)";
mysql_query($query) or die(mysql_error());
echo "Thank you for your registration $firstname $middlename $lastname! You are now an official member of the Inspiration Foundation.";
}
mysql_close($connection);
?>


But I cant figure out the prob :/ Can anyone help?

Kind Regards,
Justin

____
Edit by Jed Smith: Removed database credentials.


Top
   
 Post subject:
PostPosted: Mon Sep 14, 2009 1:16 pm 
Offline
Senior Member
User avatar

Joined: Tue Jan 04, 2005 7:32 am
Posts: 277
Website: http://www.betadome.com/
Location: Ă…lesund, Norway
Skype: neonnero
Twitter: neonnero
I think you might have to take a closer look at the file dbconnect.php, around, say, line 24 (or thereabouts). You probably have a missing paranthesis or something on that line or the previous one.


Top
   
 Post subject:
PostPosted: Mon Sep 14, 2009 1:29 pm 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
Code:
if (empty($you)) OR (empty($others));

should be
Code:
if ((empty($you)) OR (empty($others)))


Top
   
 Post subject:
PostPosted: Mon Sep 14, 2009 4:07 pm 
Offline
Senior Member

Joined: Mon Jun 16, 2008 6:33 pm
Posts: 151
Code:
$firstname = $_POST['firstname'];
$middlename = $_POST['middlename'];
$lastname = $_POST['lastname'];
$sex = $_POST($sex);
$emailaddress = $_POST['emailaddress'];
.
.
$query = "INSERT INTO ifdbt0 (memberid, firstname, middlename, lastname, sex, emailaddress) VALUES ('', '$firstname', '$middlename', '$lastname',

I hope you're going to do some sanity checks on these first...


Top
   
 Post subject:
PostPosted: Mon Sep 14, 2009 4:33 pm 
Offline
Senior Member

Joined: Mon Oct 27, 2008 10:24 am
Posts: 173
Website: http://www.worshiproot.com
Like mjrich said, you're asking for trouble if you don't check your inputs before you feed them to the database.

Also, that second to last semicolon in your insert statement should be a single quote.


~JW


Top
   
 Post subject:
PostPosted: Mon Sep 14, 2009 5:11 pm 
Offline
Senior Member
User avatar

Joined: Tue May 26, 2009 3:29 pm
Posts: 1691
Location: Montreal, QC
Also, it's generally a bad idea to post your database hostname, username and password in public.


Top
   
 Post subject: Re: Script issue
PostPosted: Mon Sep 14, 2009 6:49 pm 
Offline
Senior Member
User avatar

Joined: Tue Apr 13, 2004 6:54 pm
Posts: 833
webc0der wrote:
$query = "INSERT INTO ifdbt0 (memberid, firstname, middlename, lastname, sex, emailaddress) VALUES ('', '$firstname', '$middlename', '$lastname', '$sex', '$emailaddress;)";


Missing ' after $emailaddress (appears to have been replaced with a ; )

_________________
Rgds
Stephen
(Linux user since kernel version 0.11)


Top
   
 Post subject:
PostPosted: Mon Sep 14, 2009 6:51 pm 
Offline
Senior Member

Joined: Sun Aug 02, 2009 1:32 pm
Posts: 222
Website: https://www.barkerjr.net
Location: Connecticut, USA
Yeah, it's much better to not use database passwords and use IP-based authentication instead.


Top
   
 Post subject:
PostPosted: Tue Sep 15, 2009 10:53 am 
Offline
Senior Member
User avatar

Joined: Tue May 26, 2009 3:29 pm
Posts: 1691
Location: Montreal, QC
BarkerJr wrote:
Yeah, it's much better to not use database passwords and use IP-based authentication instead.


Woah, no way. IPs can be spoofed, although you'll have trouble getting return traffic unless you're on a LAN. Except Linodes are.

If you want to go the IP-auth route, use it in combination with a password; MySQL makes that easy, especially if you use phpMyAdmin to set it up (it's a dropdown on the create account page).


Top
   
 Post subject:
PostPosted: Tue Sep 15, 2009 9:47 pm 
Offline
Senior Member

Joined: Sun Aug 02, 2009 1:32 pm
Posts: 222
Website: https://www.barkerjr.net
Location: Connecticut, USA
I'm pretty sure that you cannot hijack IPs in the Linode networks.


Top
   
 Post subject: Re: Script issue
PostPosted: Wed Sep 16, 2009 12:56 am 
Offline
Senior Member

Joined: Fri Dec 07, 2007 1:37 am
Posts: 385
Location: NC, USA
webc0der wrote:
Code:
$host='localhost';

Good luck trying to spoof that one from anywhere ;)


Top
   
 Post subject: Re: Script issue
PostPosted: Wed Sep 16, 2009 10:30 am 
Offline
Senior Member
User avatar

Joined: Tue May 26, 2009 3:29 pm
Posts: 1691
Location: Montreal, QC
Stever wrote:
webc0der wrote:
Code:
$host='localhost';

Good luck trying to spoof that one from anywhere ;)


You didn't pay enough attention to his post:

Quote:
PHP Parse error: syntax error, unexpected T_LOGICAL_OR in /var/www/vhosts/xxx.net/httpdocs/Tim/dbconnect.php on line 24, referer: http://xxx.net/Tim/Registration.htm


Notice the hostname there :P


Top
   
 Post subject: Re: Script issue
PostPosted: Sun Sep 27, 2009 4:24 am 
Offline
Senior Member

Joined: Sat Dec 04, 2004 5:36 pm
Posts: 145
Guspaz wrote:
Stever wrote:
webc0der wrote:
Code:
$host='localhost';

Good luck trying to spoof that one from anywhere ;)


You didn't pay enough attention to his post:

Quote:
PHP Parse error: syntax error, unexpected T_LOGICAL_OR in /var/www/vhosts/xxx.net/httpdocs/Tim/dbconnect.php on line 24, referer: http://xxx.net/Tim/Registration.htm


Notice the hostname there :P


True 'nuff but look at the directory pathname -- possible he had /etc/hosts entry like: 127.0.0.1 xxx.net localhost


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: nqservices and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group