|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
pictures and numbers and text - bah
I seem to be having a problem. What I am doing it pulling pictures, their description, and their section off of the database. I got it to work, but in the loop I usually have to insert a number for num_rows and it seems that the description and section text are matched up with 1 picture ahead of where they should be.
EX: picture 1 - no text picture 2 -picture 1's text picture 3 -picture 2's text. I have been racking my brain on this and cant seem to match up the text with the picture. Is my loop wrong, or is my table id screwed up? Please help. CODE: Code:
<?php
extract($_GET);
extract($_REQUEST);
$user = "oprods";
$pass = "breakin";
$db = "pictures";
$table = $_REQUEST['table'];
$num_rows = @mysql_num_rows($result);
for ($id = 1; $id <= $num_rows; $id++ ) {
print '<TR>';
print '<TD width=33%><img src=getdata.php?id='.$id.'&table='.$table.' width=404 height=295></TD>';
print '<TD width=33%>'.$description.'</TD>';
print '<TD width=33%>'.$section.'</TD>';
print '</TR>';
$conn = @mysql_connect('localhost',$user,$pass) or die(mysql_error());
if(!is_resource($conn)) {
die("Error connecting to mysql.\n");
}
@mysql_select_db($db,$conn);
$sql = "SELECT * FROM $table WHERE id=$id";
$result = @mysql_query($sql,$conn)or die(mysql_error());
while ($newarray = @mysql_fetch_array($result, MYSQL_BOTH)) {
$description = $newarray['description'];
$section = $newarray['section'];
}
}
?>
|
|
#2
|
|||
|
|||
|
PHP Code:
PHP Code:
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. |
|
#3
|
|||
|
|||
|
that doesnt make it work.
Now the picture has an id of 0 and there is no picture with an id of 0 in my database because it starts with 1. The loops seems to stop too because no other pictures are put up. Is there supposed to be another loop of some sort of is there another problem or somethin I overlooked? |
|
#4
|
||||
|
||||
|
Try this:
PHP Code:
However you may have to change PHP Code:
PHP Code:
ID(position 0) Description(position 1) Section(position 2) one problem that I saw with your code was you were trying to get the # of entries before you even connected to the mysql server or database... should have errored out there.. but try this.. see if it helps ![]() |
|
#5
|
|||
|
|||
|
Nicat, thanks,
There are no errors or any messages indicating failure, BUT. Nothin happens. I also changed description and section as you indicated. When I typed the id number in the browser ex: &id=1 nothing happend either. Before I would see the picture and the text if i did this. Is something missing? Please reply anyone, thanks |
|
#6
|
||||
|
||||
|
You aren't getting any error messages are you? so it is connecting to the database correctly and returning values?
Where you have the if($result){ //If the result array isn't empty... make it look like this: PHP Code:
Last edited by nicat23 : June 27th, 2003 at 03:33 PM. |
|
#7
|
|||
|
|||
|
nothin is being returned except the <BR><BR>.
Well, we may be able to trace what is goin on. Its not registering values so....... |
|
#8
|
|||
|
|||
|
In place of:
PHP Code:
PHP Code:
|
|
#9
|
||||
|
||||
|
Ok do this.. add some lines to make the following code read accordingly
if($conn) { //Connected fine, continue code add this--> echo "Connected fine to the db server.<Br>\n"; if($dbConn){ //Connected to db fine, continue code add this--> echo "Connected fine to the database.<Br>\n"; $num_entries = @mysql_num_rows($num_res); add this--> echo "num_entries = $numentries<br>\n"; for ($id = 1; $id <= $num_entries; $id++ ){ add this--> echo "The position in the for loop is $id<br>\n"; if($result){ add this--> echo "Result returned more than one value"; and change print $result[$temp].' - position '.$temp.' <BR><Br>'; to echo "$result[$temp] position - $temp <br><br>\n"; my print statement might be fubar I mainly use echo... let me know what the results are |
|
#10
|
|||
|
|||
|
i narrowed it down:
the for($id = 1; $id <= $num_rows; $id++ ){ statement isnt working because nothing returns inside those brackets. Note even print "hello world"; Anything higher than that is fair game for hello world. So it must mean that is not terminating, but I dont know how to figure out why its not. |
|
#11
|
||||
|
||||
|
Quote:
then PHP Code:
|
|
#12
|
|||
|
|||
|
did you edit part of your code because i was missing the whole part from num_entries and all of the num's?
|
|
#13
|
|||
|
|||
|
WHAT THE HELL?
This is weird. It printed all of the code that you would see if you opened a jpg in wordpad. Must have printed all the text from the whole database in kinda postbinary. I know for a fact mine are all set up fine as blobs becasue they were working eariler. You seen anthing like it? I'll give you the link if you want it. |