SitePoint Sponsor |
|
User Tag List
Results 1 to 7 of 7
Thread: Help needed. Php not working
-
Aug 26, 2007, 10:11 #1
- Join Date
- Feb 2006
- Posts
- 159
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Help needed. Php not working
I need help! Spent last few hours scratching my head,trying to get some code to work.
I've just now tested something i know that does/has worked and that didnt work either. I have not used php and mysql in some time so maybe forgetting something obvious.
I'm testing it under the xp pro server iis or whatever it's called. Php code alone works. I just tested that with a piece of code to return the date.
What doesnt work is php that is working alongside mysql. Normally the two pieces of code i've just tested should return "X has been added to the database" after taking input from the user but both now just go to a blank screen. No error, no nothing. This is also what my new code is doing. Is there anything obvious you think i should check. I've not re-installed anything and it has worked in the past to test server-side code.
Any suggestions would be great. Appologise if it's obvious
-
Aug 26, 2007, 10:14 #2
- Join Date
- Nov 2004
- Location
- Right behind you, watching, always watching.
- Posts
- 5,431
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Without seeing some code it's next to impossible for anyone to help you!
-
Aug 26, 2007, 10:17 #3
- Join Date
- Feb 2006
- Posts
- 159
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
i'm pretty sure it's not an error in the code as previous working programs are now not working. Are there any settings etc to check which would stop the connection between mysql and php working?
-
Aug 26, 2007, 10:22 #4
- Join Date
- Feb 2006
- Posts
- 159
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
here is the new code though.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>LC</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<?php if (isset($_POST['emailad'])):
//connect to the db server
$dbcnx = @mysql_connect('localhost','root','xxxxxxxxx');
if(!$dbcnx)
{
exit('<p>Unable to connect to the database server at this time.</p>');
}
//select the db
if (!@mysql_select_db('lcdd'))
{
exit('<p>Unable to locate the database at this time.</p>');
}
$emailtxt = $_POST['emailad'];
$sql = "INSERT INTO emailads SET
emailtext='$emailtxt',
emaildate=CURDATE()";
if(@mysql_query($sql))
{
echo '<p>Your email address has been added to our list, Thankyou</p>';
}
else
{
echo '<p>Error adding your email address : ' . mysql_error() . '</p>';
}
?>
<?php else: // default page display?>
<!--no email address has been provided so we prompt the user for one. -->
<form action= "<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<label>Please enter you email address : <input type= "text" name= "emailad" /></label>
<input type="submit" value= "Submit" />
</FORM>
<?php endif; ?>
</body>
</html>
-
Aug 26, 2007, 11:15 #5
- Join Date
- Feb 2006
- Posts
- 159
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
anyone ANY ideas?
-
Aug 26, 2007, 14:00 #6PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>LC</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<?php if (isset($_POST['emailad'])):
// connect to the db server
$dbcnx = @mysql_connect('localhost', 'root', 'xxx');
if(!$dbcnx)
{
exit('<p>Unable to connect to the database server at this time.</p>');
}
// select the db
if (!@mysql_select_db('lcdd'))
{
exit('<p>Unable to locate the database at this time.</p>');
}
$emailtxt = $_POST['emailad'];
$sql = "INSERT INTO emailads SET
emailtext='$emailtxt',
emaildate=CURDATE()";
if(@mysql_query($sql))
{
echo '<p>Your email address has been added to our list, Thankyou</p>';
}
else
{
echo '<p>Error adding your email address : ' . mysql_error() . '</p>';
}
?>
<?php else: // default page display
?>
<!--no email address has been provided so we prompt the user for one. -->
<form action= "<?php echo $_SERVER['PHP_SELF'];
?>" method="post">
<label>Please enter you email address : <input type= "text" name= "emailad" /></label>
<input type="submit" value= "Submit" />
</FORM>
<?php endif;
?>
</body>
</html>my mobile portal
ghiris.ro
-
Sep 2, 2007, 07:59 #7
- Join Date
- Feb 2006
- Posts
- 159
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
forgot i hadnt updated you guys. i also forgot id been playing around with php 5 and had changed some settings in the ini file to make it work. Changed them back and it worked fine.
Bookmarks