Page 1 of 1

function displaying as undefined?? helllp!!!

Posted: Thu Nov 06, 2008 8:55 am
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

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

Posted: Thu Nov 06, 2008 9:07 am
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.

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

Posted: Thu Nov 06, 2008 9:33 am
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

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

Posted: Thu Nov 06, 2008 9:35 am
by onion2k
Pop a space in between * and FROM in your SQL query.

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

Posted: Thu Nov 06, 2008 9:54 am
by terra.one
oops!! lol ok done, but no change..

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

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

Posted: Thu Nov 06, 2008 9:57 am
by VladSun
What's
"SELECT *FROM bboys WHERE id = bboys"
bboys???

Try
[sql]SELECT * FROM bboys WHERE id = 'bboys'[/sql]

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

Posted: Thu Nov 06, 2008 10:05 am
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

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

Posted: Thu Nov 06, 2008 10:07 am
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!!! :)

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

Posted: Thu Nov 06, 2008 11:27 am
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...

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

Posted: Thu Nov 06, 2008 1:31 pm
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.

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

Posted: Thu Nov 06, 2008 4:22 pm
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

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

Posted: Fri Nov 07, 2008 9:30 am
by terra.one
erm , i dont understand