Hi, I'm very new to php, and I'm havin a problem with a simple script.
<html><head><title></title></head>
<body>
<?
$DBhost = "";
$DBuser = "";
$DBpass = "";
$DBName = "***";
$table = "home";
$hometext = "hometext";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
@mysql_select_db("$DBName") or die("Unable to select database $DBName");
#
$insert = mysql_query( "SELECT * FROM $table" );
$num_rows = mysql_num_rows($insert);
if ($num_rows <"1") {mysql_query ("INSERT INTO $table ($hometext) VALUES ( 'Enter Text Here')");}
#
$result=mysql_query(" SELECT $hometext FROM $table WHERE id = '1'");
$text=mysql_result($result,"hometext");
?>
Update Home Text:
<p>
<form action="homeupdateprocess.php" method="post">
<textarea name="ud_hometext" cols="50" rows="10" id="ud_hometext"><? echo "$text"?></textarea>
<input name="Submit" type="Submit" value="Update">
</p>
<?
mysql_close();
?>
</body>
</html>
Basically, the script works except for the part around the if statement at the top part (in #'s).
What I want this bit to do is look at the table, and if there are no rows in the table, to populate a single row with the hometext field value "Enter Text Here", can anyone help?