Current time: 07-29-2014, 04:37 AM Hello There, Guest! (LoginRegister)


Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My site
09-09-2004, 05:09 AM
Post: #11
RE: My site
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','',
Visit this user's website Find all posts by this user
Quote this message in a reply
09-09-2004, 05:20 AM
Post: #12
RE: My site
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.
Visit this user's website Find all posts by this user
Quote this message in a reply
09-09-2004, 05:44 AM
Post: #13
RE: My site
ok, I used your suggestion and WDZ's (desc was reserved or something like that) and now it works. Thanks Chris.

4 new questions:
Code:
<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.
Visit this user's website Find all posts by this user
Quote this message in a reply
09-09-2004, 11:31 AM
Post: #14
RE: My site
Code:
<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..
Code:
<?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
Visit this user's website Find all posts by this user
Quote this message in a reply
09-09-2004, 05:35 PM
Post: #15
RE: RE: My site
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.

Main SETI@Home project closed, but was picked up by BOINC.
It allows you to crunch data for different projects like SETI, Einstein, & more...Check it out.
Find all posts by this user
Quote this message in a reply
09-11-2004, 03:54 AM
Post: #16
RE: My site
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??
Code:
$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
Code:
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.
Visit this user's website Find all posts by this user
Quote this message in a reply
09-11-2004, 04:09 AM
Post: #17
RE: My site
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:
Code:
<?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.

Code:
$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:

Code:
<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)

Code:
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
}
?>
Visit this user's website Find all posts by this user
Quote this message in a reply
09-11-2004, 06:20 AM (This post was last modified: 09-11-2004 06:23 AM by k776.)
Post: #18
RE: My site
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) :(
Code:
if (!mysql_query("DELETE FROM download_items WHERE id = '$id'");) {
Visit this user's website Find all posts by this user
Quote this message in a reply
09-11-2004, 06:24 AM
Post: #19
RE: My site
if (!mysql_query("DELETE FROM download_items WHERE id = '$id'");) {

You dont need the ;.
Visit this user's website Find all posts by this user
Quote this message in a reply
09-11-2004, 06:55 AM (This post was last modified: 09-11-2004 06:59 AM by Matt Light.)
Post: #20
RE: My site
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
Code:
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)
}

Matt Light
MattLight.com
If you want my help, be sure to follow the posting tips.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

Contact Us | MyBB | Return to Top | Return to Content | Lite (Archive) Mode | RSS Syndication