Problem solved, thanks for suggestions everybody :)
wartotojas
Posts
-
how to change PHP code -
how to change PHP codeI do understand that bit, but how to output query results the same way as they are in while loop?
-
how to change PHP codeHi everybody, I was implementing an image gallery from one of tutorials. In this tutorial PHP opens a directory and loops through it and outputs all image files. I am looking for code solution how to change this loop to output only those images that belongs to particular image album. There should be way to run SQL query and select files and then output them, problem is I have no idea how. When I upload image I store some data to following table:
CREATE TABLE tbl_image (
im_id INT NOT NULL AUTO_INCREMENT,
im_user_name VARCHAR(25) NOT NULL,
im_album_id INT NOT NULL,
im_title VARCHAR(64) NOT NULL,
im_description TEXT NOT NULL,
im_type VARCHAR(30) NOT NULL,
im_image VARCHAR(60) NOT NULL,
im_date DATETIME NOT NULL,
PRIMARY KEY(im_id)
);here is the code piece that should be changed:
<?php
/* Configuration Start */
$thumb_directory = 'img/thumbs';
$orig_directory = 'img/original';$stage_width=600; // How big is the area the images are scattered on
$stage_height=400;/* Configuration end */
$allowed_types=array('jpg','jpeg','gif','png');
$file_parts=array();
$ext='';
$title='';
$i=0;/* Opening the thumbnail directory and looping through all the thumbs: */
$dir_handle = @opendir($thumb_directory) or die("There is an error with your image directory!");
$i=1;
while ($file = readdir($dir_handle))
{
/* Skipping the system files: */
if($file=='.' || $file == '..') continue;$file\_parts = explode('.',$file); $ext = strtolower(array\_pop($file\_parts)); /\* Using the file name (withouth the extension) as a image title: \*/ $title = implode('.',$file\_parts); $title = htmlspecialchars($title); /\* If the file extension is allowed: \*/ if(in\_array($ext,$allowed\_types)) { /\* Generating random values for the position and rotation: \*/ $left=rand(0,$stage\_width); $top=rand(0,400); $rot = rand(-40,40); if($top>$stage\_height-130 && $left > $stage\_width-230) { /\* Prevent the images from hiding the drop box \*/ $top-=120+130; $left-=230; } /\* Outputting each image: \*/ echo ' <div id="pic-'.($i++).'" class="pic" style="top:'.$top.'px;left:'.$left.'px;background:url('.$thumb\_directory.'/'.$file.') no-repeat 50% 50%; -moz-transform:rotate('.$rot.'deg); -webkit-transform:rotate('.$rot.'deg);"> <a class="fancybox" rel="fncbx" href="'.$orig\_directory.'/'.$file.'" target="\_blank">'.$title.'</a> </div>'; }
}
/* Closing the directory */
closedir($dir_ha -
Image uploads to server with php and mySQLHey everybody, I posted something simmilar while ago, but didn't received enough info. What I am looking for is php script that would allow users to create an album, upload multiple files, store files itself on server, and data about them in database. what else Im looking is ability to create thumbnail at the same time when file is uploaded. I was searching quite a lot and found this one: http://articles.sitepoint.com/article/php-gallery-system-minutes/1[^] Basically it should do everything what I am looking for, but unfortunetely I am not able to implement it. When I download source files from this tutorial, and upload them to my server, these doesnt do all the stuff. When I run preupload.php it seems that files are uploaded, and confirmation message appears, data is stored in one of the tables in database, but no files or thumbnails appears on server.... Any ideas? Am I missing something big in here or the tutorial is inncomplete? If anybody knows any other tutorials that would do something like this one pls give me a link :) Thank you in advance.
-
Little help with my php code plsI used die function few times, and it doesnt kill all process. here is full php code Im using :
<?php
// we check if everything is filled in
if(empty($_POST['fname']) || empty($_POST['lname']) || empty($_POST['email']) || empty($_POST['nickname']) || empty($_POST['pass']))
{
die('{status:0,txt:"All the fields are required"}');
}// is the email valid?
if(!(preg_match("/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $_POST['email'])))
{
die('{status:0,txt:"You haven\'t provided a valid email"}');
}$dbhost = "localhost";
$dbname = "register";
$dbuser = "*******";
$dbpass = "******";mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());$name = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$nickname = $_POST['nickname'];
$password = md5($_POST['password']);$checkuser = mysql_query("SELECT email FROM users WHERE email='$email'");
$username_exist = mysql_num_rows($checkuser);
if ( $username\_exist > 0 ){ mysql\_close(); echo 'Email already registered'; include( 'members.php' ); } else{ $query = "INSERT INTO users (name, lname, email, nickname, password) VALUES('$name', '$lname', '$email', '$nickname', '$password')"; mysql\_query( $query) or die( mysql\_error() ); mysql\_close(); echo "You have successfully Registered"; }
?>
It is still doesnt work. I used
die('{status:0,txt:"You haven\'t provided a valid email"}');
to display error message in error box, before you are redirected, I tought it will work instead of echo statment and it is working with first few fields. Like I said before records are created in database in the way they are supposed to, the only thing is that error message I want to make for email validation. Any suggestion about that, and this might sound realy dumb, but how do I make that after registration and clicking submit button users would be redirected to other page, lets say "members.php"? thanks for answers and any help :) -
Little help with my php code plshi everybody, Im new with php, started recently, Im making a registration form for my website and here is the problem. I try to check if email address entered isn't already in use. here is the code Im using:
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());$name = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$nickname = $_POST['nickname'];
$password = md5($_POST['password']);// lets check to see if the username already exists
$checkuser = mysql_query("SELECT email FROM users WHERE email='$email'");$username_exist = mysql_num_rows($checkuser);
if($username_exist > 0){
die('{status:0,txt:"This email address is already registered"}');
unset($email);
include 'register.html';
exit();// lf no errors present with the username
// use a query to insert the data into the database.$query = "INSERT INTO users (name, lname, email, nickname, password)
VALUES('$name', '$lname', '$email', '$nickname', '$password')";
mysql_query($query) or die(mysql_error());
mysql_close();echo "You have successfully Registered";
It does the job, doesnt send data to database if email is registered, but it allways displays error message
{status:0,txt:"This email address is already registered"},
and don't output message that you have been registered. If email address is unique it creates a record in a database, but displays error and doesnt redirect. Its probably something simple, but I cant figure out by my self. Anyone any ideas? By the way my form includes jQuery and few functions if it makes any difference. thanx in advance
-
uploading and storing files on server with phpthanks for help, but you missunderstood me a bit... xamp didnt wor for some reason, thus I found cheap host and got everything online. For code editing and web development Im using Dreamweaver (older, still Macromedia but I think it is basicaly the same). For php I already read loads of tutorials, and probably will be fine with upload part. what I dont know is how to setup mySQL database that it could store physical files (images in my case) or it is done in some other way? any suggestions on that part? thanx once more
-
uploading and storing files on server with phphi, I need some help, at least some guidelines where to start. Briefly, I am making a website where registered users will be able to upload their photos, create an album and some other functionality. Im new with PHP and mySQL, so have no clue where to start. Is the files would be stored in database together with other information with users details when they register, or it is some kind dedicated server part that only users can access? the thing im making is like a part of facebook or any other social websites where u can upload a bunch o photos, put them together into album...plus you can comment on others etc.. Thank You for any suggestions.
-
Post a Comment with JavaScriptHi everybody, I am building a website, it is just educational purpose website which will probably will not be hosted. and Im looking for a JavaScript that wuold allow add comments (lets say I make a post on my Blog manualy updating HTML source code and others could add a comment from the text box or something like that). What I am thinking is there any java script that enable lets say wrap a text from text box after pressing 'submit' button to <div> tags from my CSS and automaticaly update source code of HTML? Hope I was clear enough for what I am looking, Thanks for any help in advance. Domas.
-
what programm should I use for application's source code viewingthanx for your help everybody, I scrapped this idea, probably its not for my programming skills :)
-
what programm should I use for application's source code viewingSorry for not being clear enough, try to make it more clearer. Thus I am running Windows, I have an application (or software if I could say so), what it does is, works through command line. It does have a .exe and .dll files. You simply open up a command line, type in "converter.exe fileName.raw" and it converts an .raw file (picture) into .apn file (a file type used by Alpine, for their head units). Thus I managed to view a source code of that application using Net Beans, it was written in C++, and now I am wondering if it would be possible to rework same piece of code into java language? Thank You
-
what programm should I use for application's source code viewingI had opened it with Net Beans, apparently it was written in C++. Another question would be: is it difficult to rework code that would do the same thing in java? this might sound stupid, but my knowledge level in java isn't very high, and never worked with C++ either.. Thanks a lot.
-
what programm should I use for application's source code viewingHey there, I do have a small program that converts one type of image into another. It consist of .dll , .c and application files. it simply runs through command line, and does its work. Im working with java based programs and not sure if there is any way to view a source code for that one? Im wondering if there is any way to create something as GUI for it, just because using through command line isnt handy enough... Thanks for help :)