B-knotty
Members-
Posts
11 -
Joined
-
Last visited
Never
Everything posted by B-knotty
-
Someone mentioned to me that both $_GET and $_POST are both types of arrays. Would some be able to tell me exactly how they are arrays or point me to a site on the internet that explains them and similar types to me. I already know how a standard array works from watching the 3d buzz VTM's on them, I just need to find out more information about those types of data structures.
-
hah it's okay, learn something new everyday huh? Still no one can help with the connection to the database at least?
-
Okay, that makes a lot more sense now here is the code for the gallery upload <?php // Connect to database $errmsg = ""; if (! @mysql_connect("localhost","Knotty","letmein")) { $errmsg = "Cannot connect to database"; } @mysql_select_db("rudeboy"); if ($_REQUEST[completed] == 1) { // Need to add - check for large upload. Otherwise the code // will just duplicate old file ;-) // ALSO - note that latest.img must be public write and in a // live appliaction should be in another (safe!) directory. move_uploaded_file($_FILES['imagefile']['tmp_name'],"latest.img"); $instr = fopen("latest.img","rb"); $image = addslashes(fread($instr,filesize("latest.img"))); if (strlen($instr) < 149000) { mysql_query ("insert into pix (title, imgdata) values (\"". $_REQUEST[whatsit]. "\", \"". $image. "\")"); } else { $errmsg = "Too large!"; } } // Find out about latest image $gotten = @mysql_query("select * from pix order by pid desc limit 1"); if ($row = @mysql_fetch_assoc($gotten)) { $title = htmlspecialchars($row[title]); $bytes = $row[imgdata]; } else { $errmsg = "There is no image in the database yet"; $title = "no database image available"; } // If this is the image request, send out the image if ($_REQUEST[gim] == 1) { header("Content-type: image/jpeg"); print $bytes; exit (); } ?> This part of it works fine, although I need to change the way it connects to the database, I don't like the idea of having login details on each page, as I mentioned earlier ideally I want to have an include at the top of the script that points to location of the login details, this would also mean that I don't have to change all the script if I changed any of the login information. So the database connection part at the top need to be changed to include('includes/db.php'); which points to this script with all the login details. <?php $db_link = mysql_connect('localhost', 'Knotty' , 'letmein'); if (!db_link) { echo 'error connnecting to database.'; exit; } if (!mysql_select_db('rudeboy',$db_link)) { echo 'error connnecting to database.'; exit; } ?> After the image details have been stored in the database, I would like to be able to display all the images on another page by simply querying the database and then looping through all of it. something a bit like this. <?php $query = 'SELECT * FROM pix' $result = mysql_query($query, $db_link); while ($row = mysql_fetch_assoc($result)) { ?> <img src=?gim=1 width=144> <?= $title ?> <?php } ?> but I've had no luck solving either of these two problems Thanks for the help!
-
The script that I was using uploads the image to the database though CREATE TABLE gallery ( autoid int unsigned not null auto_increment primary key, title varchar(100), imgdata longblob ); I used the to create the table, when ever I do a SELECT * FROM gallery in the MySQL console it starts to spit out loads of %&7838247£^% so I assumed thats how it stored the image in the database. I'm also a bit confused other the path to the image part as well. Thanks for you're help so far, i'm still quite new at this an I need to get this problem sorted tonight.
-
Can nobody help?
-
[SOLVED] I need help adding a delete button to one of my script
B-knotty replied to B-knotty's topic in PHP Coding Help
I've managed to solve the problem , but thanks anyway! -
Thanks so much for the help so far, I've managed to get it outputting the image now. However I've got two problems I need to sort of with the script then I'll be happy with it. First I need it to loop and display all of the pictures in the database and not just one for this I assumed I'd need some sort of loops to do this. but it doesn't seem to like it. Second I need to change the log in to the database so it points to a different file with the log in details, this is for obvious security reasons. Normally I just but and include at the top of the script like this: that points to the location of the file with the log in details that looks like this. but when I remove the log in part from the top of that script it can't log into the database, what am I doing wrong? again thanks so much for the help.
-
[SOLVED] I need help adding a delete button to one of my script
B-knotty replied to B-knotty's topic in PHP Coding Help
Thanks, I'm no longer getting that error message, but the delete button still isn't working. if (isset($_GET['delete_id'])) //check to see if the delete button has been passed to the script { $query = 'DELETE FROM contact WHERE autoid = "'.$_GET['delete_id'].'"'; if (!mysql_query($query, $db_link)) { echo mysql_error(); exit; } } I was sure that should delete it. this script works by someone filling in a contact form sending it, that information is feed into the contact table, then that information is queried and displayed on another page (Admin_contact). But I wanted to add a delete button to each message so after its read it can easily be deleted, I was sure thats how its done. But when I click it the page refreshes but nothing happens. However thanks very much for the help so far, at least it does something. -
I'm really sorry but I still don't understand, don't I need to query the database to get them out? I'm still pretty new it this so sorry if this is awkward.
-
So I've managed to upload my images into a database, but I have no idea how to get them out. here's the source for my gallery upload http://rafb.net/p/B4dI3R78.html I just took that off a site and then tried to incorporate it into my own locally hosted site. I can't work out how to get the images out of the database on another script. Can someone please help?