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
trying now...................... ahhh, now we are getting somewhere

Quote:You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc,rate,type,pic) VALUES ('2','test','test','test','test','',
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());

That should work.
ok, I used your suggestion and WDZ's (desc was reserved or something like that) and now it works. Thanks Chris.

4 new questions:
<option value="0" <? if ($_REQUEST['rate'] == "0") echo "checked"; ?>>0 - Not Yet Rated</option>
That code is suppose to remember the option if I forget a feild and it resets the page but it doens't. I got text feilds to work, but not select feilds. Any suggestions.

I want a password code so only I can enter the "Add download" page. Please can someone lead me to the right site or give me a code here that can do just that??

I want it to echo each part of the script, eg:
catid added.....
mplink added.....
name added.....
etc etc

And finally, I want it to redirect me back to the add download page.

Please help.
<option value="0" <? if ($_REQUEST['rate'] == "0") echo "selected"; ?>>0 - Not Yet Rated</option>

Quote:I want a password code so only I can enter the "Add download" page. Please can someone lead me to the right site or give me a code here that can do just that??

I haven't tested this, but theoretically this should work..
<?php
$pass = "mypassword";
if($password && $password != $pass)
{
	showLogin();
}
elseif($adminpass != $pass)
{
	showLogin();
}

if($password && $password == $pass)
{
	setcookie("adminpass", $pass);
}

function showLogin();
?>
<form action="<?php echo $PHP_SELF; ?>" method="post">
<p>You must enter a valid password to continue.</p>
<p>Password: <input type="password" name="password" value="" /></p>
<p><input type="submit" name="submit" value="Login" /></p>
</form>
<?php
	exit;
}
?>
You can also search using Google or on HotScripts for good articles on authentication.

Quote:I want it to echo each part of the script, eg:
catid added.....
mplink added.....
name added.....
etc etc
I don't understand that.

Quote:And finally, I want it to redirect me back to the add download page.
header("Location: file-to-redirect-to.php");

That's assuming that you haven't printed anything to the browser yet.. That will redirect you to where you want to go.

Chris
Chris Boulton Wrote:
Quote:I want it to echo each part of the script, eg:
catid added.....
mplink added.....
name added.....
etc etc
I don't understand that.
I think he wants the script to verify it actually added the info in the db. So he wouldn't have to manually check on it.
Thanks Chris. Its working now Smile

New questions:

1. Is this how to put a [Delete] button next to name so it deletes the table I want without having to go into mySQL??
$sql = "DELETE FROM `download_items` WHERE id = '$id' LIMIT 1";
echo "[Delete]<br>\n";

2. I also want a [Edit] button that pulls the info from the download, onto a form in the right places, and allows me to edit it. How can that be done?? (just like this baord, when you click edit, it pulls the name of the thread description etc. If it is too hard, Ill just have to edit it in mySQL Sad )

3. I have game and program downloads. I want to have a select box that has to be chosen first to open up the other selections. eg: Select1 and Select2.
Select one asks for Game Download or Item downloads. If items is chosen, it displays the catagories in select2, if game is chosen, differnet ones. See what I mean?? Currently, only 1 is possible, I dont want to have to make two forms. So until Select1 is chosen, can select 2 be greyed out somehow?? Next, I need the coding. Most probably an if statment, like
if "select == item {
code to process form here into the right place (got this one)
} else {
the code to put it in another place (got this too)
}

Thanks for the help so far everyone.
I read what WDZ and Lobster said on the Messenger Plus! forums and I tend to agree with them. You should be learning this yourself - throug the manauls and stuff.

To delete stuff, you will need to do something like:
<?php
(connect to database and stuff here)
mysql_query("DELETE FROM download_items WHERE id = '$id'");
echo "Deleted $id!";
?>

(Thats a very simple version of it). You will then need to link to it from your other script, something like <a href="delete.php?id=$id">Delete</a>.

With your edit form, you can pretty much copy your add form but just set the values of the form to the current link being edited.. fetched by something like.

$query = mysql_query("SELECT * FROM download_items WHERE id='$id'");
$download = mysql_fetch_array($query);
Then $download contains the array of all of the fields from the selected record. You can do something like:

<input type="text" name="name" value="<?php echo $download['name']; ?>" />

For your categories you put a select box on a page with the two options, then you can do something like this (assuming the select box is called type)

if($type == "games")
{
 // Code to show the game downloads here
}
elseif($type == "items")
{
 // Code to show the item downloads here
}
else {
 // Nothing was chosen, lets show the downloads/item select box
?>
<form method="post" action="<?php echo $PHP_SELF; ?>">
<select name="type">
<option value="games">Game Downloads</option>
<option value="items">Item Downloads</option>
</select>
<input type="submit" />
</form>
<?php
}
?>
Firstly, its not that I am not learning, I just learn faster when told what to do, cause then I memorize it. I had almost got there using the instructions at webmonkey (delete.php was like you said, I little modified though) and I linked to delete.php, however, it would have taken longer to have found out I needed ?id=$id at the end. So thanks for that Chris.

However, anything wrong with this line?? It wont work (parse error) :(
if (!mysql_query("DELETE FROM download_items WHERE id = '$id'");) {
if (!mysql_query("DELETE FROM download_items WHERE id = '$id'");) {

You dont need the ;.
k776,

What makes you believe that we trust that you learn faster by people telling you how to do something? You've told me before that you know PHP but clearly you don't so why should we believe you aren't just using people to write your code for you? If you would take the time to read some articles and at least the language reference of the PHP website, you would have at least some idea of how to do simple stuff like an if statement correctly instead of
if "select == item {
code to process form here into the right place (got this one)
} else {
the code to put it in another place (got this too)
}
Pages: 1 2 3 4