Hi all,
I have a website that I am trying to develop a "add news" page for.
Basically people who have the authority to add news for the site can type in
their username, password, the title of the article, and the article itself
and submit it to the site (which then verifies the username and password and
if successfull adds it to the DB so the news will appear the next time
somone browses to the website.
This file is an included file into the main page...the $db variable is
valid, and works with all the other pages so far... I am really stumped and
getting frustrated.
I apologise in advance if I am including too much code in my example....the
place with the error is a couple lines from the bottom of the code sample.
My problem is that I am getting an error when i try to submit the form, code
sample is below.
The error is:
Warning: Supplied argument is not a valid MySQL-Link resource in
/usr/www/kyid/public_html/addnews.php on line 42
<?php
$size=20;$cols=46;
echo "<div align=\"center\">";
if(!$submit){
echo "<form method=\"post\" action=\"addnews.php\">\n";
echo "<table><tr><td> </td></td></table>\n";
echo "<table width=\"450\" border=\"0\" cellspacing=\"1\"
cellpadding=\"2\" align=\"center\">\n";
echo "<tr valign=\"top\">\n";
echo "<td bgcolor=\"#6A7292\" class=\"text\">* UserName<br>\n";
echo "<input type=\"text\" name=\"uname\" class=\"input\"
maxlength=\"20\" size=\"".$size."\" value=\"\">\n";
echo "<br>\n";
echo "</td>\n";
echo "<td bgcolor=\"#6A7292\" class=\"text\">* Password<br>\n";
echo "<input type=\"password\" name=\"password\" class=\"input\"
size=\"".$size."\" value=\"\">\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr valign=\"top\">\n";
echo "<td bgcolor=\"#565d77\" class=\"text\">* Headline<br>\n";
echo "<input type=\"text\" name=\"headline\" class=\"input\"
maxlength=\"40\" size=\"".$size."\" value=\"\">\n";
echo "<br>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr valign=\"top\">\n";
echo "<td colspan=\"2\" bgcolor=\"#565d77\" class=\"text\">*
Story<br>\n";
echo "<textarea name=\"newstext\" cols=\"".$cols."\"
wrap=\"VIRTUAL\" rows=\"10\" class=\"input\"></textarea>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr valign=\"top\">\n";
echo "<td bgcolor=\"#7B819A\" align=\"center\"
colspan=\"2\">\n";
echo "<input type=\"submit\" name=\"submit\" value=\"Add
Article\" class=\"submit\"><input type=\"reset\" name=\"reset\"
value=\"Clear\" class=\"submit\">\n\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table></form>\n";
}else{
/* More stuff would go in here, but this isn't working. */
/******** THE LINE BELOW THIS IS THE ERROR LINE ********/
$validate = mysql_query("SELECT username, user_password FROM users
WHERE username=".$uname,$db);
}
echo "</div>";
Thanks in advance for any help, or please let me know if this should be on
php-general instead...
Again, thanks
Keith Young.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]