function displaying as undefined?? helllp!!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
terra.one
Forum Newbie
Posts: 8
Joined: Thu Nov 06, 2008 8:47 am

function displaying as undefined?? helllp!!!

Post by terra.one »

I hope someone can help, Im having problems adding a javascript gallery to a php site...it doesnt work, and i cant figure out why not......???



this is my header section, where I have linked the css and javascript files (to the page contents php file)


<?php
if($_GET['p']=="bboys"){ ?>
<script type="text/javascript" href="<?=$PATH_TO_CSS?>jquery.js"></script>
<script type="text/javascript" href="<?=$PATH_TO_CSS?>jquery.galleria.pack.js"></script>
<link rel="stylesheet" type="text/css" href="<?=$PATH_TO_CSS?>gallery.css" />
<script type="text/javascript" href="<?=$PATH_TO_CSS?>">

jQuery(function($) {

$('.skratch_gallery').addClass('gallery_class'); // adds new class name to maintain degradability
$('.nav').css('display','none'); // hides the nav initially

$('ul.gallery_class').galleria({
history : false, // deactivates the history object for bookmarking, back-button etc.
clickNext : true, // helper for making the image clickable. Let's not have that in this example.
insert : undefined, // the containing selector for our main image.
// If not found or undefined (like here), galleria will create a container
// before the ul with the class .galleria_container (see CSS)
onImage : function() { $('.nav').css('display','block'); } // shows the nav when the image is showing
});
});

</script>


<?php


this is my page content function......php

function get_content_bboys()

{

//$query = ("SELECT *FROM bboys WHERE id = bboys);
//echo $query;
//$result = mysql_query($query);

$result = mysql_query("SELECT *FROM bboys WHERE id = bboys");

$content = "<div class='demo'>\n";
$content .= "<ul class='skratch_gallery'>\n";
$content .= "<li'>\n";

while ($row = mysql_fetch_array($result));
{


$content .= "<a href='index.php?p=bboys" . $row['id'] . "' title='" . $row['name'] . "'>
<img src='/skratch/bboys/" . $row['img_file'] . "' alt='" . $row['name'] . "' />
</a>\n";

}

$content .= "</li'>\n";
$content .= "</ul>\n";
$content .= "</div>\n";

return $content;
}

this is my url...

http://www.teragraphix.com/skratch/index.php?p=bboys
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: function displaying as undefined?? helllp!!!

Post by papa »

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/terra12/public_html/skratch/includes/page_contents.php on line 203

You need to connect to a database before doing the select query.
terra.one
Forum Newbie
Posts: 8
Joined: Thu Nov 06, 2008 8:47 am

Re: function displaying as undefined?? helllp!!!

Post by terra.one »

I am connected through my config file....

http://www.teragraphix.com/skratch/index.php?p=tshirts

this is connected to the database...its weird
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: function displaying as undefined?? helllp!!!

Post by onion2k »

Pop a space in between * and FROM in your SQL query.
terra.one
Forum Newbie
Posts: 8
Joined: Thu Nov 06, 2008 8:47 am

Re: function displaying as undefined?? helllp!!!

Post by terra.one »

oops!! lol ok done, but no change..

http://www.teragraphix.com/skratch/index.php?p=bboys
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: function displaying as undefined?? helllp!!!

Post by VladSun »

What's
"SELECT *FROM bboys WHERE id = bboys"
bboys???

Try
[sql]SELECT * FROM bboys WHERE id = 'bboys'[/sql]
There are 10 types of people in this world, those who understand binary and those who don't
terra.one
Forum Newbie
Posts: 8
Joined: Thu Nov 06, 2008 8:47 am

Re: function displaying as undefined?? helllp!!!

Post by terra.one »

i think its something to do with the " in the header section where the jquery is defined....

///ile highlight in red where the " are in the css links, and then it will show that Im not sure where the " goes for the jquery

<?php
if($_GET['p']=="bboys"){ ?>
<script type="text/javascript" href="<?=$PATH_TO_CSS?>jquery.js"></script>

<script type="text/javascript" href="<?=$PATH_TO_CSS?> /// DOES IT GO HERE??

jQuery(function($) {

$('.skratch_gallery').addClass('gallery_class'); // adds new class name to maintain degradability
$('.nav').css('display','none'); // hides the nav initially

$('ul.gallery_class').galleria({
history : false, // deactivates the history object for bookmarking, back-button etc.
clickNext : true, // helper for making the image clickable. Let's not have that in this example.
insert : undefined, // the containing selector for our main image.
// If not found or undefined (like here), galleria will create a container
// before the ul with the class .galleria_container (see CSS)
onImage : function() { $('.nav').css('display','block'); } // shows the nav when the image is showing
});
});

</script>/// DOES IT GO HERE??


<?php
terra.one
Forum Newbie
Posts: 8
Joined: Thu Nov 06, 2008 8:47 am

Re: function displaying as undefined?? helllp!!!

Post by terra.one »

VladSun wrote:What's
"SELECT *FROM bboys WHERE id = bboys"
bboys???

Try
[sql]SELECT * FROM bboys WHERE id = 'bboys'[/sql]
awesome!! that got rid of one prob, thnx!!! :)
terra.one
Forum Newbie
Posts: 8
Joined: Thu Nov 06, 2008 8:47 am

Re: function displaying as undefined?? helllp!!!

Post by terra.one »

ok i figured out i dont need a link to an file...as its a function on its own...so ive taken out the link, and its this

<?php
if($_GET['p']=="bboys"){ ?>
<script type="text/javascript" href="<?=$PATH_TO_CSS?>jquery.js"></script>
<script type="text/javascript" href="<?=$PATH_TO_CSS?>jquery.galleria.pack.js"></script>
<link rel="stylesheet" type="text/css" href="<?=$PATH_TO_CSS?>gallery.css" />
<script type="text/javascript">

jQuery(function($) {

$('.skratch_gallery').addClass('gallery_class'); // adds new class name to maintain degradability
$('.nav').css('display','none'); // hides the nav initially

$('ul.gallery_class').galleria({
history : false, // deactivates the history object for bookmarking, back-button etc.
clickNext : true, // helper for making the image clickable. Let's not have that in this example.
insert : undefined, // the containing selector for our main image.
// If not found or undefined (like here), galleria will create a container
// before the ul with the class .galleria_container (see CSS)
onImage : function() { $('.nav').css('display','block'); } // shows the nav when the image is showing
});
});

</script>


<?php
}
?>



I dont have a clue whats wrong with it tho, theres an image on the database so it should be displaying that at least, I want to break something lol...
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: function displaying as undefined?? helllp!!!

Post by RobertGonzalez »

Can you please start using the

Code: Select all

tags when posting code. Even better would be if you used

Code: Select all

as it formats the code you post nicely as PHP code. Thanks.
terra.one
Forum Newbie
Posts: 8
Joined: Thu Nov 06, 2008 8:47 am

Re: function displaying as undefined?? helllp!!!

Post by terra.one »

can anyone help me to make this work??

my header links...

Code: Select all

 
<?php
if($_GET['p']=="bboys"){ ?>
<script type="text/javascript" href="<?=$PATH_TO_CSS?>jquery.js"></script>
<script type="text/javascript" href="<?=$PATH_TO_CSS?>jquery.galleria.pack.js"></script>
<link rel="stylesheet" type="text/css" href="<?=$PATH_TO_CSS?>gallery.css" />
<script type="text/javascript"> 
    
    jQuery(function($) {
        
        $('.skratch_gallery').addClass('gallery_class'); // adds new class name to maintain degradability
        $('.nav').css('display','none'); // hides the nav initially
        
        $('ul.gallery_class').galleria({
            history   : false, // deactivates the history object for bookmarking, back-button etc.
            clickNext : true, // helper for making the image clickable. Let's not have that in this example.
            insert    : undefined, // the containing selector for our main image. 
                                   // If not found or undefined (like here), galleria will create a container 
                                   // before the ul with the class .galleria_container (see CSS)
            onImage   : function() { $('.nav').css('display','block'); } // shows the nav when the image is showing
        });
    });
    
    </script>
 
 
<?php
}
?>
 

Code: Select all

function get_content_bboys()
    
    {
    
    //$query = ("SELECT * FROM bboys WHERE id = 'bboys'");
    //echo $query;
    //$result = mysql_query($query);
    
    $result = mysql_query("SELECT * FROM bboys WHERE id = 'bboys'");
    
    $content = "<div class='demo'>\n";
    $content .= "<ul class='skratch_gallery'>\n";
    $content .= "<li'>\n";
    
    while ($row = mysql_fetch_array($result));
    {
       
    
    $content .= "<a href='index.php?p=bboys" . $row['id'] . "' title='" . $row['name'] . "'>
                        <img src='/skratch/bboys/" . $row['img_file'] . "'  alt='" . $row['name'] . "' />
                    </a>\n";
           
    }
    
    $content .= "</li'>\n";
    $content .= "</ul>\n";
    $content .= "</div>\n"; 
    
    return $content;
    }      
 
http://www.teragraphix.com/skratch/index.php?p=bboys
terra.one
Forum Newbie
Posts: 8
Joined: Thu Nov 06, 2008 8:47 am

Re: function displaying as undefined?? helllp!!!

Post by terra.one »

erm , i dont understand
Post Reply