Jump to content

Mysql Fetch Array


LightningSt

Recommended Posts

I have no idea whats wrong but this automatically generates a table based on information from the database... but when you have two appointments scheduled it freaks out... i currently only have two appointments scheduled int he database and here is what happens

 

The first row is generated properly... nothing wrong but on the second row, whether it is a different contact or not, the contact portion has a heart attack... it will still echo the name but it gives off this error

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\HUGO\appointments.php on line 79

 

Here are lines 78-80 and the entire feature is below that

 

 

$resultses = mysql_query("SELECT * FROM ci WHERE ID = '$CI'");
while ($row = mysql_fetch_array($resultses,MYSQL_ASSOC))
{

 

<table width="100%" border="2">
				<tr>
					<td>
						Contact Name
					</td>
					<td>
						From
					</td>
					<td>
						Till
					</td>
					<td>
						YYYY-MM-DD
					</td>
					<td>
						Action
					</td>
				</tr>
				<?php
					include 'library/configdb.php';
					include 'library/opendb.php';
					$resulting = mysql_query("SELECT * FROM appointment");
					while ($row = mysql_fetch_array($resulting,MYSQL_ASSOC))
						{
							$CI = $row['CIN'];
							$start = $row['Start'];
							$end = $row['Ends'];
							$date = $row['Date'];
				?>
							<form method="POST" action="?res=1">
								<tr>
									<td>
										<?php
											$resultses = mysql_query("SELECT * FROM ci WHERE ID = '$CI'");
											while ($row = mysql_fetch_array($resultses,MYSQL_ASSOC))
												{
													$title = $row['title'];
													$first = $row['first'];
													$last = $row['last'];
												}
													echo $title.' '.$first.' '.$last;
										?>
										<input type="hidden" name="hiddens" value="<?php echo $CI; ?>">
									</td>
									<td>
										<?php echo $start; ?>
									</td>
									<td>
										<?php echo $end; ?>
									</td>
									<td>
										<?php echo $date; ?>
									</td>
									<td>
										<select name="action">
											<option value="Yes">Showed For Appointment</option>
											<option value="No">Did Not Show for Appointment</option>
										</select>
									</td>
									<td>
										<input type="submit" value="Attended">
									</td>
								</tr>
							</form>
							<?php 
								include 'library/closedb.php';
						}
							?>
			</table>

Link to comment
https://forums.phpfreaks.com/topic/108934-mysql-fetch-array/
Share on other sites

fyi, doing

 

mysql_fetch_array($blah, MYSQL_ASSOC)

 

is the same as doing

 

mysql_fetch_assoc ($blah)

 

 

_assoc returns associative array

_row returns a numerical array

_array returns both without a 2nd argument, and one or the other with a 2nd argument

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/108934-mysql-fetch-array/#findComment-558886
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.