nav33n 472 Purple hazed! Team Colleague Featured Poster

Huh! Well, it likes while loop if the resource id provided to it is correct. Check your query again. Maybe some details are missing.

nav33n 472 Purple hazed! Team Colleague Featured Poster

$query = "SELECT * FROM images_broad WHERE id=`1`";
$result=mysql_query($query);
while($row=mysql_fetch_row($result, MYSQL_ASSOC)){
echo '<img src="'.$row.'"/>';
}

Should be

$query = "SELECT * FROM images_broad WHERE id=`1`";
$result=mysql_query($query);
while($row=mysql_fetch_array($result, MYSQL_ASSOC)){
echo '<img src="'.$row['broad1'].'"/>';
}
nav33n 472 Purple hazed! Team Colleague Featured Poster

Can you post your latest code which showed PickupAddressPostcode on top ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Give this a shot

<input type='text' name='PickupAddressPostCode' value='<?=$row['PickupAddressCode'];' />

Umm.. doesn't make any difference since <?php echo $row is same as <?=$row; ?> .. Why not have your input box in the loop itself ? ie.,

while($row = mysql_fetch_array($result)){
echo "<input type='text' name='PickupAddressPostcode' value='".$row['PickupAddressCode']."'>";
}
nav33n 472 Purple hazed! Team Colleague Featured Poster

And, if your table has more than 1 row, use while loop.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Array ( [0] => image/thumbs/thumb_1207138801.gif
[broad1] => image/thumbs/thumb_1207138801.gif )

Thats because, mysql_fetch_array returns both numeric index array and associated array name. Try mysql_fetch_array($result,MYSQL_ASSOC) and print !

nav33n 472 Purple hazed! Team Colleague Featured Poster

should the where clause look something like this

Help with Code Tags
(Toggle Plain Text)

$sql="UPDATE images_broad SET broad1='$broad1name2' WHERE broad1=`1`";

$sql="UPDATE images_broad SET broad1='$broad1name2' WHERE broad1=`1`";

if this line is correct it is effecting the preview page. when that page is accessed is says there is a problem with the mysql line

No. You are trying to update broad1 column where broad1 = 1. I hope your table has an id(counter) field which is an auto-increment field ? Use that to update the record.

if this line is correct it is effecting the preview page. when that page is accessed is says there is a problem with the mysql line

Help with Code Tags
(Toggle Plain Text)

while($row=mysql_fetch_array($result, MYSQL_ASSOC)){

while($row=mysql_fetch_array($result, MYSQL_ASSOC)){

should the while be taken out and the line edited so it looks like this

Help with Code Tags
(Toggle Plain Text)

$result=mysql_fetch_array($result, MYSQL_ASSOC)){

Basically, If your table has only 1 record, you don't need a while loop. But if your table has more than 1 record, then to fetch all the records, you have to use a while loop. My suggestion for you is, search for "file upload+php" in google. You will get alot of examples. Use one to upload an image to the server. While you upload an image to the server, save the path in the table(Insert a record and not update). So, whenever you upload an image, a path will be in the table. And for listing the images in the …

nav33n 472 Purple hazed! Team Colleague Featured Poster

When you upload a path, a new row is inserted and the "path" is stored in a column. But when you update the table(without a where clause), it updates all the rows and replace all the path values stored in the column with the new value. So, You should have a where clause while using update.

nav33n 472 Purple hazed! Team Colleague Featured Poster

if the code works for the images_broad table why will this not work for the new tables that have been created.

because there is nothing stored in the table before this code was run should i use the insert into query so that the table gets populated at least once and then change it to update.

Exactly ! You have to insert a record to the table in order to update it. And again, dont update all the records, but only one record.

nav33n 472 Purple hazed! Team Colleague Featured Poster

$sql="UPDATE images_tab SET tab1='$tab1name2'";

You are updating all the records to tab1name. Have a where clause and update only 1 record. Since you are updating all records, it shows the same image in the preview page.

nav33n 472 Purple hazed! Team Colleague Featured Poster

the type=file part of the form does this not mean that this is a browse button i have not changed this yet but if i put type=file1 would the file browse button still appear?

i will check and get back

No. Not that. <input type="file" name="uploadimage1"> This one.

nav33n 472 Purple hazed! Team Colleague Featured Poster

if (isset($_POST)) {

is open and not closed.

jino commented: thx u very much +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

Yep, I guess..

nav33n 472 Purple hazed! Team Colleague Featured Poster

I checked it and this is what I find.
http://acmeart.co.uk/mercury/image/thumbs/thumb_1207128520.jpg all the images have the same path. That is why the image is being repeated. While fetching the path from the table, check if it returns the right path. Then, there are only 2 input type='file'. So whenever you upload an image and then another (using the same upload file tag) it gets replaced.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Whenever a user opens a page, add page's name to the session variable. Since you are adding it to the session, If he opens another window for the same page, redirect him to error page.
Eg.

//This is main.php which has link to page1.php
<a href="page1.php">Page 1</a>

This is page1.php

<?php
session_start();
if($_SESSION['page']=="page1"){
 header("location: error.php");
} else {
	$_SESSION['page']="page1";
}
echo "Hi";
?>

Now, right click on the page1.php and open it in a new page. It displays "Hi". Do the same again and you will be redirected to error.php.

Cheers,
Naveen

carobee commented: Great mind always at work +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

Do you have these files on a server so that we can check the output ? Because, I don't understand what exactly is the problem..

kevin wood commented: very good at what he does. +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

Right after session_start, print $_SESSION and tell us what it prints.

nav33n 472 Purple hazed! Team Colleague Featured Poster

I don't see variable $newname2 getting a value.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Hmm.. Seems good.. But, the only problem I can think off is, either $_SESSION is empty or the query returns records with null values.
Oh, hey btw, use { } for your while loop.

nav33n 472 Purple hazed! Team Colleague Featured Poster

mysql_select_db("", $connection)

You haven't specified the Dbname. Turn off the notices OR (which is a very good option) initialize your variables before using it to get rid of notices.

nav33n 472 Purple hazed! Team Colleague Featured Poster

I am not really sure why you got "Query was empty" message. :-O

nav33n 472 Purple hazed! Team Colleague Featured Poster

This is strange. But one thing.

$sqlrow = mysql_fetch_row($sqlresult); <<-- THIS IS LINE 109 -->>
if ($sqlrow == 0) {

You have used mysql_fetch_row. It returns rows as numeric array . So, you can't give, $sqlrow. You can use mysql_fetch_array instead. I am not sure if this will help, but remove ` from your query !

nav33n 472 Purple hazed! Team Colleague Featured Poster

Post your complete latest code.

nav33n 472 Purple hazed! Team Colleague Featured Poster

When you start the script, make $myusername null. Then assign a value to it and then print it.
ie., $myusername="";

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) Heh! I just finished my work, had nothing to do. So, I was being patient :P ! Anyways, ciao !

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yep. Use an img src tag to get the image from the filename. echo "<img src='$filename'>";

nav33n 472 Purple hazed! Team Colleague Featured Poster

Okay ! some mistakes.
1. Insert into tablename (columnname) [b]values[/b] ('value'); Anyway, I dont know how your function make_thumb work, but this works.

<?php
 
include "db.php";
$con = mysql_pconnect("$xxx","$xxxxx","$xxxxx") or die ("QUERY ERROR: ".mysql_error());
$db = mysql_select_db($xxxxx, $xxxxx) or die("QUERY ERROR: ".mysql_error());
 //define a maxim size for the uploaded images
 define ("MAX_SIZE","500"); 
 // define the width and height for the thumbnail
 // note that theese dimmensions are considered the maximum dimmension and are not fixed, 
 // because we have to keep the image ratio intact or it will be deformed
 define ("WIDTH","200"); 
 define ("HEIGHT","200"); 

  // this is the function that will create the thumbnail image from the uploaded image
 // the resize will be done considering the width and height defined, but without deforming the image
 function make_thumb($img_name,$filename,$new_w,$new_h)
 {
 	//get image extension.
 	$ext=getExtension($img_name);
 	//creates the new image using the appropriate function from gd library
 	if(!strcmp("jpg",$ext) || !strcmp("jpeg",$ext))
 		$src_img=imagecreatefromjpeg($img_name);

  	if(!strcmp("png",$ext))
 		$src_img=imagecreatefrompng($img_name);
	
	if(!strcmp("gif",$ext))
		$src_img=imagecreatefromgif($img_name);

 	 	//gets the dimmensions of the image
 	$old_x=imageSX($src_img);
 	$old_y=imageSY($src_img);

 	 // next we will calculate the new dimmensions for the thumbnail image
 	// the next steps will be taken: 
 	// 	1. calculate the ratio by dividing the old dimmensions with the new ones
 	//	2. if the ratio for the width is higher, the width will remain the one define in WIDTH variable
 	//		and the height will be calculated so the image ratio will not change
 	//	3. otherwise we will use the height ratio for the image
 	// as a result, only one of the dimmensions …
nav33n 472 Purple hazed! Team Colleague Featured Poster

Yes. It is possible to store the path of the file. The datatype is varchar as you have mentioned. Store the path, then display the image by retrieving the path from the table and use it in the image tag.

$query = "select path from table";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
$path = $row['image_path'];
echo "<img src = '$path'>"; //list all the images 
}
kevin wood commented: is very helpful and gives good feedback +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

Dude, try out a simple query to insert a record to the table. When you upload an image, add the path to the table. Do you upload an image through a script or manually ? Check this example. http://www.tizag.com/phpT/fileupload.php $target_path will be the path where the image is gonna be stored. Save it in the table. If that doesn't work, you have to post your latest complete code.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yes. It is possible to fetch the files from the server without storing the filename in mysql. You have to open the directory , read the directory and list the files ! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

UPDATE images_broad SET broad1='image/thumbs/thumb_1206968603.gif'

That wouldn't put anything to the table, since your table has no records. Try this.

$query = "insert into images_broad (broad1) values ('image/thumbs/thumb_1206968603.gif'); 
mysql_query($query);

Then execute the above script to check if a record exists or not. I am sure it will say, "There is something!" !

nav33n 472 Purple hazed! Team Colleague Featured Poster

hmm.. In that case, try a simple script like this one.

$query = "select * from images_broad";
$result = mysql_query($query);
if(mysql_num_rows($result) > 0){
 echo "There is something!"; //prints if there are more than 0 records
} else {
echo "There is nothing !"; // prints if there is nothing in the table
}

Tellme what it prints.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Well, I hope you have phpmyadmin atleast ? If you do, you can execute your query in phpmyadmin. You can use sqlyog to connect to remote server actually.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Hmm.. Did you execute the query select * from images_broad in mysql console ? Did you get any output ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

First of all, you are updating the table without any condition. So, it will update all the records and set broad1 = image/thumbs/thumb_1206960238.gif. Secondly, its echo $result and not echo $result ['$thumb_name'];

nav33n 472 Purple hazed! Team Colleague Featured Poster

Your query should be SELECT * FROM details WHERE columnname LIKE '$_POST[search]'% LIMIT 0, 50

nav33n 472 Purple hazed! Team Colleague Featured Poster

Hmm.. Print out your query ( print $sql; )and execute it in mysql console or phpmyadmin. See if it returns any row. If it doesn't, then the problem is not with the query and there are no records. If it returns an error, post that error.

nav33n 472 Purple hazed! Team Colleague Featured Poster

It should be echo $result['thumb_name'];

nav33n 472 Purple hazed! Team Colleague Featured Poster

Since you are including the script which creates the table, whenever you include that script, it tries to create the table causing the error.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Why do you want to create a table from php anyway ? Everytime you run your script, it will include table_create.php and tries to create the table all the time. Check this link . Add 'if not exists' in your create table query.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Then your query is wrong. What exactly are you trying to do with that query ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Same error ? Try mysql_error() with die statement. Also print out your query and tell us what it says !

nav33n 472 Purple hazed! Team Colleague Featured Poster

SELECT * FROM details WHERE '$_POST[metode]' LIKE '$_POST[search]'% LIMIT 0, 50

I guess $_POST is the column name ? Print out the query, execute it in phpmyadmin/ mysql console. Check the result. Oh, also, remove the @ symbol from

$row = @mysql_fetch_array($query)

nav33n 472 Purple hazed! Team Colleague Featured Poster
<html>
<body>
<form method="post" name="test">
<input type="button" name="button1" value="login" onClick="javascript: 

document.test.action='login.php';document.test.submit();"><input type="button" name="button2" value="Register" 

onClick="javascript: document.test.action='register.php';document.test.submit();">
</form>
</body>
</html>

You can do it this way.

nav33n 472 Purple hazed! Team Colleague Featured Poster
$query = "SELECT address_code FROM address WHERE userID= '".$myuserID."'";
$result = mysql_query($query);

<td><input type="text" name="PickupAddressPostCode" value="<?php echo $result['address_code']; ?>" /></td>

Matti Ressler
Suomedia

That should actually be

$query = "SELECT address_code FROM address WHERE userID= '".$myuserID."'";
$result = mysql_query($query);
$row = mysql_fech_array($result); //or while($row = mysql_fetch_array($result)) if your query returns more than 1 row
<td><input type="text" name="PickupAddressPostCode" value="<?php echo $row['address_code']; ?>" /></td>

Cheers,
Naveen

nav33n 472 Purple hazed! Team Colleague Featured Poster

@ doesn't help it error handling, but it supresses the errors.

if(@mysql_num_rows($result) > 0){ //do something

This above code, supresses the warning if there is something wrong with the query. Its not a good practice to have @, because it makes your life very difficult to know where the exact error is.

nav33n 472 Purple hazed! Team Colleague Featured Poster

I got your PM. I couldn't reply you back cuz maybe you have disabled PM. Anyways, good luck !

nav33n 472 Purple hazed! Team Colleague Featured Poster
<?php
session_start();
?>
<html>
<head>
<script type="text/javascript">
function login() {
	alert('<?php echo $_SESSION['un']; ?>');
}
</script>
</head>
<body bgcolor="#f1f3f3">
<form method="post" onsubmit="javascript:login();">
<?php
$g=hi;
$_SESSION["un"]=$g;
?>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>

Try this. Btw, you didn't have session_start in your script.

nav33n 472 Purple hazed! Team Colleague Featured Poster

It is possible. But you can do it this way.

<script type='text/javascript'>
alert(<?php echo $_SESSION['un']; ?>);
</script>

If that doesn't work, try, alert('<?php echo $_SESSION['un']; ?>'); Cheers,
Naveen

nav33n 472 Purple hazed! Team Colleague Featured Poster

Use is_numeric instead of is_int :) !