Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 26th, 2005, 7:48 PM   #1
theguy0000
Programmer
 
Join Date: Jul 2005
Posts: 73
Rep Power: 4 theguy0000 is on a distinguished road
keep getting an error

when i go to a page called "sql_test.php". the file consists of this code:

[PHP]<?php
if( !$userdata['session_logged_in'] )
{
die("Please login to access this page.");
}

if ($user_data['user_level'] != ADMIN) {
die("You must be an admin to access this page.");
}
else {
// Connecting, selecting database
$link = mysql_connect('host', 'username', 'password')
die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db('my_database') or die('Could not select database');

// Performing SQL query
$query = "CREATE TABLE sqltest ('' TYPE=default) ALTER TABLE sqltest ADD rowtest TINYINT(1) DEFAULT '1' NOT NULL SELCT * FROM sqltest";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());

// Printing results in HTML
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";

// Free resultset
mysql_free_result($result);

// Closing connection
mysql_close($link);
}
?>[/PHP]

except, of course, the host, username, and password are the real ones.

the error says

Quote:
Parse error: parse error, unexpected T_EXIT in /home/xemocne/public_html/fatcats/sql_test.php on line 13
theguy0000 is offline   Reply With Quote
Old Jul 26th, 2005, 7:55 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
else {
// Connecting, selecting database
$link = mysql_connect('host', 'username', 'password')
   die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
Incomplete setting up and blocking of conditional constructs, missing semicolon.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers

Last edited by sykkn; Jul 27th, 2005 at 9:01 AM.
DaWei is offline   Reply With Quote
Old Jul 26th, 2005, 7:58 PM   #3
theguy0000
Programmer
 
Join Date: Jul 2005
Posts: 73
Rep Power: 4 theguy0000 is on a distinguished road
aww darnit im soo stupid. i just gave you all the info you need to connect to my sql database T_T

please edit that out of your post.

thanks for the help.

Last edited by theguy0000; Jul 26th, 2005 at 8:10 PM.
theguy0000 is offline   Reply With Quote
Old Jul 26th, 2005, 8:37 PM   #4
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
We don't edit it out of our post, you edit it out of YOUR post or get a moderator to do it. Yeah, lotsa people do that, you gotta catch it .
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 26th, 2005, 8:50 PM   #5
theguy0000
Programmer
 
Join Date: Jul 2005
Posts: 73
Rep Power: 4 theguy0000 is on a distinguished road
lol yeah ill be more careful about that
theguy0000 is offline   Reply With Quote
Old Jul 26th, 2005, 9:16 PM   #6
sykkn
Hobbyist Programmer
 
Join Date: Apr 2004
Location: Texas
Posts: 106
Rep Power: 5 sykkn is on a distinguished road
check the following line ...

$link = mysql_connect('host', 'username', 'password')
   die('Could not connect: ' . mysql_error());

I think you probably meant ...

$link = mysql_connect('host', 'username', 'password') or die('Could not connect: ' . mysql_error());

or better yet ....

$link = mysql_connect('host', 'username', 'password');
if(!$link) {
   die('Could not connect: ' . mysql_error());
}
DaWei,

He has edited his user information from his post. Would you do the same to yours?
__________________
[ [ SykkN alloc ] initWithThePowerTo: destroyYouAll ];
/* Don't make me use it! */
sykkn is offline   Reply With Quote
Old Jul 26th, 2005, 9:18 PM   #7
skuinders
Hobbyist Programmer
 
skuinders's Avatar
 
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4 skuinders is on a distinguished road
Quote:
Originally Posted by DaWei
We don't edit it out of our post, you edit it out of YOUR post or get a moderator to do it. Yeah, lotsa people do that, you gotta catch it .
I think he meant edit your post because you quoted the sensitive information that he posted.
EDIT: sykkn pointed this out.

I saw this when it was first posted and I was going to see if he used that same password for this site and, if so, I was going to log on as him and answer his question, but I got distracted.
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand."
- B. Russell

http://web.bryant.edu/~srk2
skuinders is offline   Reply With Quote
Old Jul 26th, 2005, 9:39 PM   #8
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Oh, lol, the quote....I will get it . Nope, edit time expired, mod will have to do it.....
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 27th, 2005, 9:03 AM   #9
sykkn
Hobbyist Programmer
 
Join Date: Apr 2004
Location: Texas
Posts: 106
Rep Power: 5 sykkn is on a distinguished road
DaWei, I got it. Thx.
__________________
[ [ SykkN alloc ] initWithThePowerTo: destroyYouAll ];
/* Don't make me use it! */
sykkn is offline   Reply With Quote
Old Jul 27th, 2005, 9:59 AM   #10
theguy0000
Programmer
 
Join Date: Jul 2005
Posts: 73
Rep Power: 4 theguy0000 is on a distinguished road
Quote:
check the following line ...

$link = mysql_connect('host', 'username', 'password')
   die('Could not connect: ' . mysql_error());

I think you probably meant ...

$link = mysql_connect('host', 'username', 'password') or die('Could not connect: ' . mysql_error());
it tells me there is an unexpecter "or" or something like that.

Quote:

or better yet ....

 $link = mysql_connect('host', 'username', 'password');
 if(!$link) {
    die('Could not connect: ' . mysql_error());
 }
ill try that.

this is the exact code from the php manual, except [php]if( !$userdata['session_logged_in'] )
{
die("Please login to access this page.");
}

if ($user_data['user_level'] != ADMIN) {
die("You must be an admin to access this page.");
}
else {[/php] and i dont think that would effect how the code works, would it?

edit: now i get an error:
Quote:
Warning: mysql_connect(): Can't connect to MySQL server on 'ftp.t35.com' (110) in /home/xemocne/public_html/fatcats/sql_test.php on line 3
Could not connect: Can't connect to MySQL server on '<host>' (110)
maybe im giving it the wrong username/password?
theguy0000 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:33 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC