View previous topic :: View next topic |
Author |
Message |
pezza2323 -
Joined: 27 Jul 2005 Posts: 10
|
Posted: Mon Aug 01, 2005 10:49 am Post subject: whats wrong with this script |
|
|
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 |
|
|
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Mon Aug 01, 2005 10:50 am Post subject: |
|
|
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 |
|
|
pezza2323 -
Joined: 27 Jul 2005 Posts: 10
|
Posted: Mon Aug 01, 2005 10:53 am Post subject: |
|
|
nope i just get a blank screen |
|
Back to top |
|
|
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Mon Aug 01, 2005 11:12 am Post subject: |
|
|
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 |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Mon Aug 01, 2005 12:29 pm Post subject: |
|
|
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 |
|
|
roganty -
Joined: 08 Jun 2004 Posts: 357 Location: Bristol, UK
|
Posted: Mon Aug 01, 2005 3:35 pm Post subject: Re: whats wrong with this script |
|
|
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 |
|
|
Tim1681 -
Joined: 17 Jan 2005 Posts: 160 Location: Bristol, CT, USA
|
Posted: Mon Aug 01, 2005 4:50 pm Post subject: |
|
|
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 |
|
|
k1ll3rdr4g0n -
Joined: 04 Jul 2004 Posts: 609
|
Posted: Mon Aug 01, 2005 7:18 pm Post subject: |
|
|
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 |
|
|
|