•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 375,198 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,986 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser:
Views: 1495 | Replies: 38 | Solved
![]() |
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,057
Reputation:
Rep Power: 8
Solved Threads: 229
•
•
•
•
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 preview screen, get all the records, use a while loop to fetch all the records and then display it using <img src> tag.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
on the preview page the code used to display the image which is
i have changed the code so it prints out what is in the table the code now looks lie this
the result that it prints on the screen seems to suggest that the same image is being entered into the table twice. here is what was printed
Array ( [0] => image/thumbs/thumb_1207138801.gif
[broad1] => image/thumbs/thumb_1207138801.gif )
$query = "SELECT * FROM images_broad";
$result=mysql_query($query);
while($row=mysql_fetch_array($result, MYSQL_ASSOC)){
echo '<img src="'.$row['broad1'].'"/>';
}i have changed the code so it prints out what is in the table the code now looks lie this
$query = "SELECT broad1 FROM images_broad"; $result=mysql_query($query); print_r(mysql_fetch_array($result));
the result that it prints on the screen seems to suggest that the same image is being entered into the table twice. here is what was printed
Array ( [0] => image/thumbs/thumb_1207138801.gif
[broad1] => image/thumbs/thumb_1207138801.gif )
i have set an id counter but when i try to set the where clause to id=1 it does not like the while loop on the preview page. the path is being stored to the database fine but i think it is storing it more than once.
i need to look up the code so when the image is being displayed it only displays one row from the table and not all the rows thus taking out the while loop.
i need to look up the code so when the image is being displayed it only displays one row from the table and not all the rows thus taking out the while loop.
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,057
Reputation:
Rep Power: 8
Solved Threads: 229
•
•
•
•
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 !
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,057
Reputation:
Rep Power: 8
Solved Threads: 229
i have changed the code now so it is only trying to display one row from the table but i am getting an error which is as follows but do you no what this means.
Wrong parameter count for mysql_fetch_row() in /home/acmeart/public_html/mercury/broad_prev.php on line 58
the code which i am using now looks like this
Wrong parameter count for mysql_fetch_row() in /home/acmeart/public_html/mercury/broad_prev.php on line 58
the code which i am using now looks like this
$query = "SELECT * FROM images_broad WHERE id=`1`";
$result=mysql_query($query);
while($row=mysql_fetch_row($result, MYSQL_ASSOC)){
echo '<img src="'.$row['broad1'].'"/>';
}•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,057
Reputation:
Rep Power: 8
Solved Threads: 229
•
•
•
•
$query = "SELECT * FROM images_broad WHERE id=`1`";
$result=mysql_query($query);
while($row=mysql_fetch_row($result, MYSQL_ASSOC)){
echo '<img src="'.$row['broad1'].'"/>';
}
php Syntax (Toggle Plain Text)
$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'].'"/>'; }
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,057
Reputation:
Rep Power: 8
Solved Threads: 229
Huh! Well, it likes while loop if the resource id provided to it is correct. Check your query again. Maybe some details are missing.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb MySQL Marketplace
Similar Threads
Other Threads in the MySQL Forum
- Previous Thread: creating tables
- Next Thread: Queries and sub-queries



Linear Mode