I am having problems loading images from my database. I think it's something with the variable...i am new to PHP and have a project i need to finish by Tuesday. Your help is appreciated.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>SMRTCV</title>
    <meta name="description" content="Demo page for FlowGallery jQuery plugin - image gallery based on cover flow effect." />
    <meta name="author" content="Boris Searles">

    <link rel="stylesheet" href="css/skin.css" type="text/css" media="screen" charset="utf-8" />

    <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script src="js/jquery.easing.1.3.js" type="text/javascript"></script>
    <script src="js/jquery.flowgallery.min.js" type="text/javascript"></script>
    <script type="text/javascript" charset="utf-8">
      $(function() {
        $('#gallery').flowGallery({
          easing: 'easeOutCubic',
          imagePadding: 6,
          thumbWidth: 120
        });
      });
    </script>
  </head>
  <body>

    <body>
        <div id = "wrapper">
            <div id = "header"><a href-"http://www.mysphinx.net"><img src = "http://www.obinnaizeogu.com/mysphinx/images/SMRTCV_LOGOTYPE.gif" alt = "SMRTCV" width="107" height="18" border="0"/></a>
            </div>
                <div id = "menu">
                    <ul>
                        <li>Refine</li>
                        <li>Create a Spec</li>
                        <li>Mail</li>
                        <li>Casting Board</li>
                    </ul
                </div>
                    <div>
                        <p class="name">Sign In</p>
                        <p class="name">Forgot Password?</p>
                    </div>
                        <div class="search">
                            <form id="searchform" action="http://www.mysphinx.net/" method="get">
                                <fieldset>
                                    <div class="form">
                                        <input id="s" class="field" type="text" name="s" value="">
                                            <input id="searchsubmit" class="submit" type="submit" value="">
                                    </div>
                                </fieldset>
                            </form>  
                        </div>





 <?php



        $sql = "SELECT models_ID, profile_image, photo1, photo2, photo3\n"
            . "FROM photos_models\n"
            . "WHERE profile_image LIKE \'SigridAgren.jpg\' LIMIT 0, 30 ";    

        $img_src = $row['1'];





?>




      <div id="content">

        <ul class="gal" id="gallery">
          <li><img src="http://www.obinnaizeogu.com/mysphinx/models/women/smart_gallery/lightbox/updated-images-04-26-11/<?=$img_src?>" alt="Sigrid Agren" title="Sigrid Agren" /></li>

        </ul>

      </div><!-- #content -->
    </div><!-- #wrapper -->

  </body>
</html>

im not sure what you are tryin to do with the code...but your sql query is not getting executed any where....

$sql = "select * from something";
$res = mysql_query($sql);
$row = mysql_fetch_row($res);
$img_src = $row[1];

you code should be something like this ...

I get this error when I load the page:


Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in

that means either you are passing the wrong parameter to the function or your query is wrong or query is not returning any rows...

i suggest you read up an online tutorial on this first and then proceed with your project ...

When you get following error:
"Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in "
You should echo/print your query and try execute it on your database using your favorite mysql client tool be it phpmyadmin or heidisql and see if it brings the result?
Mostly if connection is proper it will be query problem. so just make sure that.

Following posts may be helpful to you:
http://blogs.digitss.com/php/reading-mssql-blog-column-data-with-php/
http://blogs.digitss.com/database/mysql/heidisql-5-1-good-has-got-better/

that means either you are passing the wrong parameter to the function or your query is wrong or query is not returning any rows...

i suggest you read up an online tutorial on this first and then proceed with your project ...

I got to figure it out, but it's only loading 1 field from database and not the entire row

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>SMRTCV</title>
    <meta name="description" content="Demo page for FlowGallery jQuery plugin - image gallery based on cover flow effect." />
    <meta name="author" content="Boris Searles">

    <link rel="stylesheet" href="css/skin.css" type="text/css" media="screen" charset="utf-8" />

    <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script src="js/jquery.easing.1.3.js" type="text/javascript"></script>
    <script src="js/jquery.flowgallery.min.js" type="text/javascript"></script>
    <script type="text/javascript" charset="utf-8">
      $(function() {
        $('#gallery').flowGallery({
          easing: 'easeOutCubic',
          imagePadding: 6,
          thumbWidth: 120
        });
      });
    </script>
  </head>
  <body>

    <body>
		<div id = "wrapper">
			<div id = "header"><a href-"http://www.mysphinx.net"><img src = "http://www.obinnaizeogu.com/mysphinx/images/SMRTCV_LOGOTYPE.gif" alt = "SMRTCV" width="107" height="18" border="0"/></a>
			</div>
				<div id = "menu">
					<ul>
						<li>Refine</li>
						<li>Create a Spec</li>
						<li>Mail</li>
						<li>Casting Board</li>
					</ul
				</div>
					<div>
						<p class="name">Sign In</p>
						<p class="name">Forgot Password?</p>
					</div>
 						<div class="search">
							<form id="searchform" action="http://www.mysphinx.net/" method="get">
								<fieldset>
									<div class="form">
										<input id="s" class="field" type="text" name="s" value="">
											<input id="searchsubmit" class="submit" type="submit" value="">
									</div>
								</fieldset>
							</form>	
 						</div>
 				
 				
 				
 				
 				
 <?php

 
		
		$result = mysql_query($sql = "SELECT models_ID, profile_image, photo1, photo2, photo3\n"
    		. "FROM photos_models\n"
    		. "WHERE models_ID = '15' ");
    		
		if (!$result) {
   		 echo 'Could not run query: ' . mysql_error();
    	exit;
		}
		
		$row = mysql_fetch_row($result);


   

    	
    	
    	
    	
?>

            				
        				

      <div id="content">
        
        <ul class="gal" id="gallery">
          <li><img src="http://www.obinnaizeogu.com/mysphinx/models/women/smart_gallery/lightbox/updated-images-04-26-11/<?=$row[1]?>" alt="Sigrid Agren" title="Sigrid Agren" /></li>

        </ul>
       
      </div><!-- #content -->
    </div><!-- #wrapper -->

  </body>
</html>

Can I ask, why are you using the 'new line' in your sql query?

Can I ask, why are you using the 'new line' in your sql query?

I copy pasted from phpMyAdmin create php code

DeIntegro,

The reason you're only getting one row is because you're querying for one row. You need to query an array of rows.

$row = mysql_fetch_[b]row[/b]($result);

should be

$row = mysql_fetch_[b]array[/b]($result);

DeIntegro,

The reason you're only getting one row is because you're querying for one row. You need to query an array of rows.

$row = mysql_fetch_[b]row[/b]($result);

should be

$row = mysql_fetch_[b]array[/b]($result);

This is not true.
Both functions fetch one row from the query and store it in an array.
The only difference between them is how the array in which the row is stored is constructed:
mysql_fetch_row returns an enumerated array (eg. {[0] => a, [1] => b})
mysql_fetch_assoc returns an associative array (eg. {[x] => a, [y] => b})
mysql_fetch_array returns an array containing both of these (eg. {[0] => a, [x] => a, [1] => b, [y] => b}).

To get multiple rows from your query simply call mysql_fetch_array/assoc/row again and again until it returns false:

while($row = mysql_fetch_array($sql)){
    // Do something with the row
}
commented: Nice explanation +13
while($row=mysql_fetch_row($result))
{

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.