whats wrong with this script

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
pezza2323
-


Joined: 27 Jul 2005
Posts: 10

PostPosted: Mon Aug 01, 2005 10:49 am    Post subject: whats wrong with this script Reply with quote

can someone plz tell me what is wrong with this script

<?php
mysql_connect('localhost', 'pezza', 'guide');

mysql_select_db('guide') or die( "Unable to select database");

if(isset($_POST['submit'])) {

$username=$_POST['username'];



$sql = mysql_query("INSERT INTO `namelist` ( `username` , `date` ) VALUES ('$username', '$date');");

echo "Thank you, your name had been added!";

}

?>
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Mon Aug 01, 2005 10:50 am    Post subject: Reply with quote

Do you get any errors when the file is executed? If so please post them so we have a better idea as to what the problem is.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
pezza2323
-


Joined: 27 Jul 2005
Posts: 10

PostPosted: Mon Aug 01, 2005 10:53 am    Post subject: Reply with quote

nope i just get a blank screen
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Mon Aug 01, 2005 11:12 am    Post subject: Reply with quote

Are you sure php is working correctly? If so, make sure showing errors is enabled. Add this code to the top of your file.

Code:
ini_set("display_errors", 1);


This will temporaly set displaying errors on for this script.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Mon Aug 01, 2005 12:29 pm    Post subject: Reply with quote

pezza2323 wrote:
nope i just get a blank screen

Have a look on log/cgi.log for the error messages.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
roganty
-


Joined: 08 Jun 2004
Posts: 357
Location: Bristol, UK

PostPosted: Mon Aug 01, 2005 3:35 pm    Post subject: Re: whats wrong with this script Reply with quote

pezza2323 wrote:
can someone plz tell me what is wrong with this script


stcik an else clause in
for example
Code:
<?php
mysql_connect('localhost', 'pezza', 'guide');

mysql_select_db('guide') or die( "Unable to select database");

if( isset($_POST['submit']) ){
 $username = $_POST['username'];

 $sql = mysql_query("INSERT INTO `namelist` ( `username` , `date` ) VALUES ('$username', '$date');");

 echo "Thank you, your name had been added!";
}else{
 echo "No data sent";
}

?>


what happens now?
_________________
Anthony R

Roganty
| Links-Links.co.uk
Back to top View user's profile Send private message Visit poster's website
Tim1681
-


Joined: 17 Jan 2005
Posts: 160
Location: Bristol, CT, USA

PostPosted: Mon Aug 01, 2005 4:50 pm    Post subject: Reply with quote

Code:
$sql = mysql_query("INSERT INTO `namelist` ( `username` , `date` ) VALUES ('$username', '$date');");


I would have to say take out the ; after ('$username', '$date') and see what happens:

Code:
$sql = mysql_query("INSERT INTO `namelist` ( `username` , `date` ) VALUES ('$username', '$date')");

_________________
mysql> SELECT * FROM users WHERE clue > 0;
0 rows returned.

Back to top View user's profile Send private message AIM Address
k1ll3rdr4g0n
-


Joined: 04 Jul 2004
Posts: 609

PostPosted: Mon Aug 01, 2005 7:18 pm    Post subject: Reply with quote

Personally I put the query in a string called $query then put it to the mysql server.

But yeah do what Tim1681 says and put the ; at the end because the ; means its the end of the command, and tells php to go to the next line for the next command.
_________________
Back to top View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum


Powered by phpBB phpBB Group