MyBB Community Forums

Full Version: My site
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
Thanks to a friend of mine, I have started turning some of my site into sql quiries. One of the lines is:
echo "<table border=1 class=double summary=Downloads><tr><td><font color=#ffff00><b>" . $row["name"] . "</b></font> " . $row["mplink"] . "<br>" . $row["desc"] . "<br><hr><font color=#ffff00><b>Download page</b></font> " . $row["dllink"] . "<br><b>Type:</b> " . $row["type"] . "</td></tr></table><br>" ;
What I want to do is to link Download page with . $row["dllink"] .. I tired this but it doesn't work Sad I get T_STRING errors or something like it.
echo "<table border=1 class=double summary=Downloads><tr><td><font color=#ffff00><b>" . $row["name"] . "</b></font> " . $row["mplink"] . "<br>" . $row["desc"] . "<br><hr>" <a href=. $row["dllink"] .> "<font color=#ffff00><b>Download page</b></font>" </a> "<br><b>Type:</b> " . $row["type"] . "</td></tr></table><br>" ;
Any help would be nice.
echo "<table border=1 class=double summary=Downloads><tr><td><font color=#ffff00><b>" . $row["name"] . "</b></font> " . $row["mplink"] . "<br>" . $row["desc"] . "<br><hr><a href=". $row["dllink"] ."><font color=#ffff00><b>Download page</b></font>" </a> "<br><b>Type:</b> " . $row["type"] . "</td></tr></table><br>" ;

Try that?
thats the same code I tried to use.. Not to worry though. Mnjul over at the Msgplus boards told me how.
Try to put $row["name"], etc... into { and }
{$row["name"]} , {$row["mplink"]},...
How do you write infomation/text to a database?? Im using my own form, set with
method="post" action="<? echo $PHP_SELF; ?>"
with
<?
require ("scripts/add.php");
?>
at the top of the page. What do I add in scripts/add.php to upload the following fields to a table called download_items with username, password and database name in scripts/config.php??
Quote:catid,
mplink,
name,
dllink,
desc,
rate,
type,
and pic

Also, what is a good php password code so stop visitors going into this page im making to put things into the database?? Maybe storing the username and password I choose in the database then asking for it?? Any help would be nice.
First make sure you have an open connection to MySQL.

Then you do something like..

mysql_query("INSERT INTO download_items (catid,mplink,name,dllink,desc,rate,type,pic) VALUES ('$catid','$mplink','$name','$dllink','$desc','$rate','$type,'$pic')");

Or if you're using the MyBB connection to the database you can change mysql_query to $db->query

In the example, i'm assuming those are the values of the field.. and if mplink is an auto_increment field (like a primary key) then you would change '$mplink' (in the query to NULL (making sure you don't put the NULL in quotation marks).

For password protection, you can just create a form asking for the password. Check the password at the top of your script to see if its the right one, then set a cookie so the admin pages can be accessed multiple times without entering the password each time.
ok, im using:
<?
require_once ("scripts/config.php");

$errors = array();
if ($_SERVER['REQUEST_METHOD']=="POST"){
$errors = process_form($errors);
}
function process_form($errors) {

$catid = $_REQUEST['catid'] ;
$mplink = $_REQUEST['mplink'] ;
$name = $_REQUEST['name'] ;
$dllink = $_REQUEST['dllink'] ;
$desc = $_REQUEST['desc'] ;
$pic = $_REQUEST['pic'] ;
	
if (empty($catid)) {
    $errors["No catid"]="Empty catid";
    }
if (empty($mplink)) {
    $errors["No mplink"]="Empty mplink";
    }
if (empty($name)) {
    $errors["No name"]="Empty name";
    }
if (empty($dllink)) {
    $errors["No dllink"]="Empty dllink";
    }
if (empty($desc)) {
    $errors["No desc"]="Empty desc";
    }
if (empty($pic)) {
    $errors["No pic"]="Empty pic";
    } 
if (count($errors) == 0) {

mysql_query("INSERT INTO download_items (catid,mplink,name,dllink,desc,rate,type,pic) VALUES ('$catid','$mplink','$name','$dllink','$desc','$rate','$type,'$pic')");
header( "Location: scripts/add2.htm" );

}
return $errors;
}
function print_error($error) {
  echo "<b><font color=red>Error:</b> $error</font><br /><br />";
}
?>
but it doens't work, any ideas?? (config hold the database name, username and password.
"It doesn't work"? I don't think anyone can help you unless we know what's wrong Toungue
Well neither do I :p

no errors, it does exactly what I want it to (check for missing fields, if none process, if some show error on the form)

It just doesn't insert into the database, I have no idea why.
mysql_query("INSERT INTO download_items (catid,mplink,name,dllink,desc,rate,type,pic) VALUES ('$catid','$mplink','$name','$dllink','$desc','$rate','$type,'$pic')") or die(mysql_error());

Try that..
Pages: 1 2 3 4