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

Ajax is the solution for your problem.

architact 25 Junior Poster

If you don't want database included then try using google search for your site, I don't know exactly how to put it on the site, but google is your friend. And if you want to use database apache2triad is your friend. download it, install it and then i will lead you further.

architact 25 Junior Poster

please send me the complete code.

architact 25 Junior Poster

thanks a lot langsor it is working now, you are a real legend.

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

thanx langsor
it is not working in both...

architact 25 Junior Poster

set the form action to search.php and set the id of search field to searchterm.

<?php
//connect your server
mysql_connect("localhost","username","password");
//connect your db
mysql_select_db("database");

$term = $_POST['searchterm'];
//in the below line replace tbl with the table name and the column with the column name(you want to search) in that table
$dat = mysql_query("SELECT * FROM tbl WHERE colum LIKE '%$term'") or die(mysql_error());
if($data = mysql_fetch_array($dat))
echo mysql_num_rows($dat)." result(s) found";
do{
echo $data['id']; // replace id with the column you want to display as result
}
while($data = mysql_fetch_array($dat));
}
else{
echo "Sorry no results found :(";
}
?>

use this code in your search.php
also read this

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
$term = $_POST['searchterm'];
$dat = mysql_query("SELECT * FROM tbl WHERE colum LIKE '%$term'") or die(mysql_error());
if($data = mysql_fetch_array($dat))
echo mysql_num_rows($dat)." result(s) found";
do{
// display results with echo
}
while($data = mysql_fetch_array($dat));
}
else{
echo "Sorry no results found :(";
}
architact 25 Junior Poster

It is happening because GB Library, required for using this function is not installed with php on your pc.

architact 25 Junior Poster

It is not working without any error, I am not receiving data in the database, but 1.php is working without ajax but not working with ajax.

architact 25 Junior Poster

Why this code is not working.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="javascript">
var http="";
if(navigator.appName == "Microsoft Internet Explorer"){
http = new ActiveXObject("Microsoft.XMLHTTP");
}
else{
http = new XMLHttpRequest();
}
function insert(){
document.getElementById('error').innerHTML = "Please wait a second";
var tp = document.getElementById('type').value;
var it = document.getElementById('item').value;
http.open('GET', '1.php?type='+tp+'&item='+it);
http.send = null;
if(http.readyState == 4){
document.getElementById('error').innerHTML = "Data Inserted";
}
}
</script>
<style type="text/css">
<!--
body,td,th {
	font-family: Comic Sans MS;
}
-->
</style></head>

<body>
<form action="javascript:insert()" method="get">
  <table width="422" cellspacing="3" cellpadding="3">
    <tr>
      <td width="66">Type</td>
      <td width="333"><input name="type" type="text" id="type" /></td>
    </tr>
    <tr>
      <td>Item</td>
      <td><input name="item" type="text" id="item" /></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" name="Submit" value="Insert" onclick="insertg();"/></td>
    </tr>
  </table>
</form>
  <div id="error"></div>
</body>
</html>

And the 1.php

<?php
mysql_connect("localhost","name","password") or die(mysql_error());
mysql_select_db("database")or die(mysql_error());
$type = $_GET['type'];
$item = $_GET['item'];
if($type <> ""){
mysql_query("INSERT INTO likings (type, item) VALUES('$type', '$item')") or die(mysql_error());
}
?>
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

Can you show your code or at least auery?

architact 25 Junior Poster

On your page give same id to all the combo boxes and place [] after their id. On your php page use this.

// I assume the id of all the boxes to be [B]boxes[][/B]
<?php
$boxes = $_POST['boxes'];

foreach($boxes as $k){
echo $k;    // will display the selected value of each combo box
        	// Or what you want to do with the boxes
}
?>
architact 25 Junior Poster

Don't Know exactly, you can google it.

architact 25 Junior Poster

I think that's the only way.

architact 25 Junior Poster

you cannot test mail on your localhost try it from a free web server, like www.111mb.net

architact 25 Junior Poster

I don't have any link with www.111mb.net, just told you for the sake of help :)

architact 25 Junior Poster

You cannot send email from your localhost, you will need a testing server who supports mail function like, www.111mb.net, they will offer you 400mb space without any charges you can test your mail function there. you Just need to create an account on that site.

architact 25 Junior Poster

I want to know what are the usages of $_SERVER and $_ENV in php. Or for what they can be used.

architact 25 Junior Poster

Means the same what I said. :)

architact 25 Junior Poster

I don't have the code but i can tell you what's the logic behind it i think there is a table in your database in which you are storing your user login or other information, in that table create a new column and update that column on page load with the users name or id on that time. and when you want to display the recent visitors display the 10 results and select them as no one gets repeated.

architact 25 Junior Poster

thanks alot you guys

architact 25 Junior Poster

Thanks alot R0bb0b

architact 25 Junior Poster

No one is here to help Me :(

architact 25 Junior Poster

Instead of importing variable values from file why don't you import values from database it will be easy to edit their values from admin panel.

architact 25 Junior Poster

Insted of actual date format use timestamp format returned by php time() function. Then you will be able to use >, < and equal to.

architact 25 Junior Poster

the command used for this purpose is.
mysql_query("UPDATE tbl set field='$value' WHERE id='$id'");

architact 25 Junior Poster

Hello Every one I have a problem in my website that i want to generate the user ids like 0u3012ewd0 as we see on many sites but don't have any idea how to do this.

Please help me in this problem

Thanks alot.

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

thanks alot MVied and vicky i will try your methods. thanks

architact 25 Junior Poster

Hello I have designed a website in which users can create their account and then add or delete their likings, favoorite songs, what i want is that i want them to be able to arrange their likings by moving up and down. for this i need a procedure for swapping the two rows of table so that they can arrange their liking and songs. Please help me, if you have any other idea please share with me.

Thanks in advance.

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

can you help me in getting the time of server instead of users pc.

architact 25 Junior Poster

Check out

Apache 2 triad

architact 25 Junior Poster

hey guys,
I have made a database using mysql and php. I have also put in a search option. But what i want is that if the item which is being searched for is not in the databse it should return "Database Not Found". I am not able to execute this.
Please help me on this.

i assume the name of variables to be dat and data

$dat = mysql_query("SELECT * ........."); // the query you used
if(!$data = mysql_fetch_array($dat)){
echo "No results found";
}
architact 25 Junior Poster

try

$dat = mysql_query("SELECT * FROM table");
$data = mysql_fetch_array($dat);

do
{
if($data['text']==""){
continue;
}
echo $data['text'];
}
while($data = mysql_fetch_array($dat));

text is the field which you want to check if it is empty or not.

Shanti C commented: smart reply.... +2
architact 25 Junior Poster

try

<script language="javascript" type="text/javascript">
function foc(){
document.getElementById('textfieldid').focus();
}
</script>
<body onload="foc();">
architact 25 Junior Poster

I don't know asp but in javascript it looks something like this.
document.placeholder.src = "hello.gif"

architact 25 Junior Poster

Hello,
I have designed a website which let the users create account and use our services, my client asked me to design a page which will show all the online members at that time, the solution i have figured out is that i have create a column in my user table in database, when a user login it changes to 1 and when the user signs out it changes to 0. the problem is if the user close the browser and leave the site without signing out it still shows the user as online. I am using sessions in php please help me how to avoid this.

Thanks in advance

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.