Forum Moderators: coopster

Message Too Old, No Replies

Error in Php/MySql script for searchable news database

Internal Server Error "File not Found"

         

Senmar50

4:14 am on Sep 21, 2004 (gmt 0)

10+ Year Member



Hi All,

I'm new to this forum. It's great! I'm also new php/mysql. Here goes... Remember..I am very new to this. I hope I don't waste your time.

These are two scripts I tried to create, by using bits and pieces from other scripts. My mission is for site visitors to leave a message or comment that will be added to our database. Database is called: News_Articles; Table: ccds_news. Table has six fields(6), which includes the (ID).

Thanks in Advance
Senmar
SMA

Submit an Article
<?
$DBhost = "";
$DBuser = "";
$DBpass = "";
$DBName = "News_Articles";
$table = "ccds_news";
$dbconn=mysql_connect("localhost","",""); or die("Unable to connect to database");

mysql_select_db("$DBName"); or die("Unable to select database $DBName");
$results=mysql_query("INSERT INTO $ccds_news (article_title, author_name, date_created, content, url)
VALUES("'$article_title"','"$author_name"','"$date_created"',"'$content"',"'$url"')");
or die(mysql_error());

mysql_close();

print "<html><body><center>";
print "<p>Thankyou For Your Comments<p>";
print "Article Name: $article_name<br>";
print "Author Name: $author_name<br>";
print "Date: $date_created";
print "Content: $content";
print "URL: $url";
print "</body></html>";
?>

$DBhost = "";
$DBuser = "";
$DBpass = "";
$DBname = "News_Articles";
$table = "ccds_news";

$dbconn=mysql_connect("localhost", "myself", "youbet"); OR DIE("DB connection unavailable");
mysql_select_db( "News_Articles") or die( "Unable to select database");
?>

Search DataBase
<?

$XX = "No Record Found, to search again please close this window";
//query details table begins
$query = "SELECT * FROM ccds_news
while ($row = @mysql_fetch_array($query))
{
$id=$_POST["id"];
$article_title=$_POST["article_title"];
$author_name=$_POST["author_name"];
$date_created=$POST["date_created"];
$content=$_POST["content"];
$url=$_POST["url"];
//table layout for results

print ("<tr>");
print ("<td>$article_title</td>");
print ("<td>$author_name</td>");
print ("<td>$date_created</td>");
print ("<td>$content</td>");
print ("<td>$url</td>");
print ("</tr>");
}

//below this is the function for no record!
if (!$variable1)
{
print ("$XX");
}
//end
?>

mincklerstraat

10:11 am on Sep 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to webmasterworld Senmar50 - [webmasterworld.com...] - and happy scripting.

Something which occurs to me when reading your post: where's the question?

coopster

12:23 pm on Sep 21, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I believe it's in the subtitle of the post...

Internal Server Error "File not Found"

...which is probably referring to your web server moreso than the script. Are you sure you have the file on the web server and are typing the url in correctly?

Senmar50

2:15 pm on Sep 21, 2004 (gmt 0)

10+ Year Member



Hi

Thanks for responding. My question should have been; why am I getting this Internal Server Error; and are there problems with my script?

Uploading to server... The scripts are contained in the "cgi-bin" folder in my httpdocs. I uploaded the scripts using MS Frontpage 2002. Maybe the problem lies with using Frontpage? Should I have used an FTP application to upload the scripts.

Question? Should the scripts also be in the "cgi-bin" folder located on my webhost's server, because when I click on the folder on their server, it's empty.

HELP PLEASE..
Thanks in Advance,
Senmar
SMA

[edited by: coopster at 3:18 pm (utc) on Sep. 21, 2004]
[edit reason] removed specifics [/edit]

coopster

3:44 pm on Sep 21, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Let's start with the server issue first and a really simple script. That way, we can make sure you are getting to the PHP page and that the PHP parser is indeed working on your server. Create a file with just the following code in it:
<?php 
phpinfo();
?>
Save it as "mypage.php" in the root directory of your public pages. Now try to open the file in your web browser. You should lots of PHP information listed on the page. Does that work?

Senmar50

4:03 pm on Sep 21, 2004 (gmt 0)

10+ Year Member



Hi Coopster,

I still get the Internal Server Error, after uploading the mypage.php.

Senmar...totally baffled

Senmar50

5:43 pm on Sep 21, 2004 (gmt 0)

10+ Year Member



Hi Coopster,

I've contacted my webhost. There's something I'm doing wrong. When I get the facts, I'll return.

Thanks
Semar

Senmar50

1:34 pm on Sep 22, 2004 (gmt 0)

10+ Year Member



Hi Coopster,

I ran the <?phpinfo();?> and it worked. I ran a few minors php scripts and they worked also. I had to remove all the php scripts from the cgi-bin folder, and put them the directory with my httpdocs.

Now...I have a couple scripts I need help with. The php script below suppose to let the visitor post a news article on our website; and upon submitting the article, a thankyou screen should appear with the information they submitted. When I tested the message.html form, the results.php page was blank. Can you please explain what I am doing wrong here?

1. results.php
(Submit Article)
<?php
$DB_host = "localhost";
$DB_user = "";
$DB_pass = "";
$DB_Name = "News_Articles";
$DB_table = "ccds_news";
$dbconn=mysql_connect("localhost","",""); or die("Unable to connect to database");

mysql_select_db("$News_Articles"); or die("Unable to select database $DB_Name");
$results=mysql_query("INSERT INTO $ccds_news (article_title, author_name, date_created, content, url)
VALUES("'$article_title"','"$author_name"','"$date_created"',"'$content"',"'$url"')");
or die(mysql_error());

mysql_close();

print "<html><body><center>";
print "<p>Thankyou For Your Comments<p>";
print "Article Name: $article_name<br>";
print "Author Name: $author_name<br>";
print "Date: $date_created";
print "Content: $content";
print "URL: $url";
print "</body></html>";
?>

The next script is a search database php script. I know there are errors in this script. Help! I also got a blank page when hit I hit the submit button on the html form doc. Help me please. (If you can)

2. script.php
(Search Database)

<?
$hostname = "localhost";
$username = "";
$password = "";
$dbName = "News_Articles";
$usertable = "ccds-news";
$show_all = `Select * From ccds_news`;

mysql_connect($localhost, $, $) OR DIE(mysql_error ());
mysql_select_db( "$News_Articles") or die( mysql_error());

//query details table begins
mysql_query( $Show_all) or die (mysql_erros());
$results = `mysql_query($Show_all) or die (mysql_error())`;
while ($row = mysql_fetch_array($results))
{
$view_ccds_news = ID_number:` .$row["id"]; <br/>
$view_ccds_news = article_title:` .$row["article_title"]; <br/>
$view_ccds_news = author_name:` .$row["author_name"]; <br/>
$view_ccds_news = date_created:` .$row["date_created"]; <br/>
$view_ccds_news = content:` .$row["content"];<br/>
$view_ccds_news = url:` .$row["url"];<br/>
//table layout for results
}
echo (`$view_ccds_news`);

print ("<tr>");
print ("<td>$variable1</td>");
print ("<td>$variable2</td>");
print ("<td>$variable3</td>");
print ("<td>$variable4</td>");
print ("<td>$variable5</td>");
print ("</tr>");
}
//below this is the function for no record!
if (!$variable1)
{

}
//end
?>

<center>
<table border="1" cellpadding="5" cellspacing="0" bordercolor="#000080">
<tr>
<td width="60"><b>id</b></td>
<td width="150"><b>article_title</b></td>
<td width="70"><b>author_name</b></td>
<td width="150"><b>date_created</b></td>
<textarea name="content" cols="50" rows="10">Content</textarea>
<td width="150"><b>url</b></td>
</tr>
</table>
</center>

Thanks in Advance,
Senmar

coopster

3:59 pm on Sep 22, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Do you have error_reporting() [php.net] turned on so you can see if you are getting any messages?

Senmar50

4:40 pm on Sep 22, 2004 (gmt 0)

10+ Year Member



I don't think so. How do I turn it on?

Senmar

Senmar50

4:55 pm on Sep 22, 2004 (gmt 0)

10+ Year Member



I checked the phpinfo and here is some info...

error reporting...2039
error prepend_string..no value
error_log...no value
error append_string...no value

display error..off
display_start-up error...off

Senmar

henry0

5:23 pm on Sep 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you might not having access to your PHP.ini file in a shared server environment
so add to your script on the top of the page

<?
error_reporting (E_ALL);
?>

regards

Henry