architact 25 Junior Poster

weired its working on my pc, try the attaced files

architact 25 Junior Poster

Check this one

<?php
include 'Images_db_connect.php';
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");
//define a maxim size for the uploaded images in Kb
 define ("MAX_SIZE","75"); 
if(isset($_FILES['file']['name']) && $_FILES['file']['name']<>""){
$typ = $_FILES['file']['type'];
if($typ == "image/gif" || $typ == "image/png" || $typ == "image/jpeg" || $typ == "image/pgif" || $typ == "image/ppng" || $typ == "image/pjpeg"){
$uploaddir = "images/";
$uploadimages = $uploaddir.$_FILES['file']['name'];
if(move_uploaded_file($_FILES['file']['tmp_name'], $uploadimages)){
$imagename = 'image name';
$caption = 'caption';
$category = 'category_name';

$sql = "INSERT into photos (image_name, caption, image_path, category) VALUES ('$imagename', '$caption', '$uploadimages', '$category')";
mysql_query($sql) or die(mysql_error());

echo "File successfully copied";
}
else{
echo "Copy unsuccessful";
}
}
else{ 
echo "Incorrect file type";
}
}
else{
echo "No file selected";
}
?>
architact 25 Junior Poster

it can be relative, please try a gif or png file and then tell me the result.

architact 25 Junior Poster

Check the folder where image is to be copied, the script is copying the file or not??

architact 25 Junior Poster

In your php file
convert this
if(isset($_FILES) && $_FILES<>""){
to
if(isset($_FILES)){

architact 25 Junior Poster

Sorry for late reply, try this code I hope it will fix your problem.

<?php
include 'Images_db_connect.php';
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");
//define a maxim size for the uploaded images in Kb
 define ("MAX_SIZE","75"); 
if(isset($_FILES['file']['name']) && $_FILES['file']['name']<>""){
$typ = $_FILES['file']['type'];
if($typ == "images/gif" || $typ == "images/png" || $typ == "images/jpeg" || $typ == "images/pgif" || $typ == "images/ppng" || $typ == "images/pjpeg"){
$uploddir = "images/";
$uploadimages = $uploaddir.$_FILES['file']['name'];
if(move_uploaded_file($_FILES['file']['tmp_name'], $uploadimages)){
$imagename = 'image name';
$caption = 'caption';
$category = 'category_name';

$sql = "INSERT into photos (image_name, caption, image_path, category) VALUES ('$imagename', '$caption', '$uploadimages', '$category')";
mysql_query($sql) or die(mysql_error());
echo "File successfully copied";
}
else{
echo "Copy unsuccessful";
}
}
else{ 
echo "Incorrect file type";
}
}
else{
echo "No file selected";
}
architact 25 Junior Poster

yes it is due to quots. :)

architact 25 Junior Poster

try using this :-/

if($typ == "images/gif" || $typ == "images/png" || $typ == "images/jpeg" || $typ == "images/pgif || $typ" == "images/ppng" || $typ == "images/pjpeg"){
architact 25 Junior Poster

Try this code

<?php
include 'Images_db_connect.php';
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");
//define a maxim size for the uploaded images in Kb
 define ("MAX_SIZE","75"); 

if(isset($_POST['Submit'])){
$typ = $_FILES['file']['type'];
if(isset($_FILES['file']['name'])){
if($typ == "images/gif" || $typ == "images/png" || $typ == "images/jpeg" || $typ == "images/pgif ||$typ" == "images/ppng" || $typ == "images/pjpeg"){
$uploddir = "images/";
$uploadimages = $uploaddir.$_FILES['file']['name'];
if(move_uploaded_file($_FILES['file']['tmp_name'], $uploadimages)){

$imagename = 'image name';
$caption = 'caption';
$category = 'category_name';

$sql = "INSERT into photos (image_name, caption, image_path, category) VALUES ('$imagename', '$caption', '$uploadimages', '$category')";
mysql_query($sql) or die(mysql_error());
	echo '<h1>Copy unsuccessfull!</h1>';
	$errors=1;
}}}}

//If no errors registred, print the success message
 if(isset($_POST['Submit']) && !$errors) 
 {
 	echo "<h1>File Uploaded Successfully!</h1>";
 }
mysql_close();

 ?>
architact 25 Junior Poster

can you mention error on line 12, i mean statement

architact 25 Junior Poster

Line 11 is still wrong $FILES is wrong.

if(isset($_POST['Submit']))

bracket is missing.
correct these two errors if it is still not working tell me or if a error is given please mention it.

architact 25 Junior Poster

please send me the complete code.

architact 25 Junior Poster

on line 11 $FILES is wrong $_FILES is correct, I will give you details but right now i am in a hurry. See ya later.

architact 25 Junior Poster

or create sessions variables of county and state and then access them on the page you want to show info. Or else use the method of dickersonka

architact 25 Junior Poster
if(isset($_POST['Submit']))

Where is starting bracket of if body?? :)

architact 25 Junior Poster

Instead of exploding and getting the extension use the mime type of the images (images/gif for firefox and safari, images/pgif for IExplorer). Because if you use the method of getting extension then the users will upload any thing after changing the files extension. e.g if a file is doc.docx they will rename it as doc.gif then your code will accept it.

<?php
$typ = $_FILES['file']['type'];
if(isset($FILES['file']['name'])){
if($typ == "images/gif" || $typ == "images/png" || $typ == "images/jpeg" || $typ == "images/pgif ||$typ" == "images/ppng" || $typ == "images/pjpeg"){
$uploddir = "images/";
$uploadimages = $uploaddir.$_FILES['file']['name'];
if(move_uploaded_file($_FILES['file']['tmp_name'], $uploadimages)){
//insert data or other collected info into db.
}
}
}
?>

Using this code you don't have to worry about getting extension or lowering extension. Just use a check of file size. This code will allow user to upload .jpg, .gif, .png files.

architact 25 Junior Poster

Hey
I host a website for a sports team, theres a nominations page where each member, when logged in, can cast a vote to whoever in the team they want to be captain for a tournament.

The Problem is when someone votes i store the id, name and there vote (nothing complicated), however when i want to retreive the data im using this.

if ($_SESSION['loggedin'] == true) {
$login_test = true;
$getvotes = "SELECT vote FROM `votes` where vote=1";
$collect = mysql_query($getvotes) or die (mysql_error());
$one = mysql_num_rows($collect);

$getvotes = "SELECT vote FROM `votes` where vote=2";
$collect = mysql_query($getvotes) or die (mysql_error());
$two = mysql_num_rows($collect);

$getvotes = "SELECT vote FROM `votes` where vote=3";
$collect = mysql_query($getvotes) or die (mysql_error());
$three = mysql_num_rows($collect);

$getvotes = "SELECT vote FROM `votes` where vote=4";
$collect = mysql_query($getvotes) or die (mysql_error());
$four = mysql_num_rows($collect);

}

the variable $one, $two ect.. are just the user id of the person being voted for.
This works fine however, i need to add 32 more candidates. This amount of query would take forever.

Is there any way i can collect it as an array the then sort it.
any help would be greatly appreciated

Thanks

try this

if ($_SESSION['loggedin'] == true) {
$login_test = true;
$getvotes = "SELECT vote FROM `votes` ORDER by vote ASC";
$collect = mysql_query($getvotes) or die (mysql_error());
$one = mysql_num_rows($collect);
architact 25 Junior Poster

Try this code

<?php
$host=""; // Host name 
$username=""; // Mysql username 
$password=""; // Mysql password 
$db_name="images"; // Database name 
$tbl_name="categories"; // Table name
 
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$sql = mysql_query("SELECT id,category_name FROM categories ORDER BY category_name"); 
$row = mysql_fetch_array($sql);
?>
<select name="Categor_name">
<?php do{ ?>
<option value="<?php echo $row['id']; ?>"><?php echo $row['category_name']; ?> </option>
<?php } while($row = mysql_fetch_array($sql));?>
</select>
architact 25 Junior Poster

I am recommending it because he is using fetch array before while loop, and then the program comes to loop and encounters the fetch array again and moves to next index in array. that's why if he is using fetch array before loop he should use do while.

architact 25 Junior Poster

Instead of while use a do while loop it will automatically fix the problem.
And also remember it is a good practice to use do while when displaying data from database.

architact 25 Junior Poster

try this code
void reset(int *board)
and in calling reset(arrayname)
in passing by raference we pass the address to the function as we do it in pointers i hope it will work.
you can not pass the reference of array because it gives error if you want to pass it's address you have to use pointers because logically an array's name is also a pointer so we can pass it to functio.

architact 25 Junior Poster

Dear Rleeq!
This usuallu happens due to virus which arrived almost a year ago but that's not the only reason for that it can be caused by the error in some hardware especially ram try changing your ram or try defragmenting your hard drive also make sure that if some has set a timer that automatically turns off your matchine..