Jump to content

icue

Members
  • Posts

    20
  • Joined

  • Last visited

Posts posted by icue

  1. Ok, I think I am making some progress.

     

    As suggested I put the function supplied by Mac_gyver at the top of the "plog-function.php" file.

     
    However when I ran it I get the following error:
     
    Fatal error: Call to a member function data_seek() on a non-object in /htdocs/mysite/portfolio/plog-includes/plog-functions.php on line 4
     
    From this function
    • function mysqli_result($result , $offset , $field = 0){
    •     $result->data_seek($offset);
    •     $row = $result->fetch_array();
    •     return $row[$field];
    • }
    This is the function I am calling mysqli_result() from:
     
    function plogger_picture_comment_count() {
      $row = $GLOBALS['current_picture'];
      $comment_query = "SELECT COUNT(`id`) AS `num_comments` FROM `".PLOGGER_TABLE_PREFIX."comments`
      WHERE approved = 1 AND `parent_id`='".$row['id']."'";
      $comment_result = run_query($comment_query);
      $num_comments = mysqli_result($row, 0, 'num_comments');
      return $num_comments;
    }
     
    Is this error caused because the example supplied is written the object way and not the procedural way.
     
    I did some more searching and found this example function:
     
    function soda_mysqli_result($result , $offset , $field = 0){
        if (mysqli_num_rows($result) && $offset <= (mysqli_num_rows($result)-1) && $offset >= 0){
    mysqli_data_seek($result,$offset);
    $resrow = mysqli_fetch_row($result);
    if (isset($resrow[$field])){
    return $resrow[$field];
    }
    }
    return false;
    }
     
    This gave the following error:
    Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, array given in /htdocs/mysite/portfolio/plog-includes/plog-functions.php on line 4
     
    Some bits that were not working before almost work but it is not finding the images in the database.
    Sorry but I don't know how to correct these errors. Any further assistance would be much appreciated.
  2. Hi, 

     

    Sorry but still don't get it. I have been trying to teach myself but there is beyond my knowledge. The gallery app is

    quite a big app written by someone else and is no  longer being updated by the developer.

     

    Based on the suggestions I replaced the following lines

     

    Line 2103

    $num_items = mysql_result($result, 0, 'num_items');

    with

    list($num_items) = $items_query->fetch_row();

     

    Line 2650

    $num_comments = mysql_result($comment_result, 0, 'num_comments');

    with

    list($num_comments) = $items_query->fetch_row();

     

    but I get the following errors:

    Notice: Undefined variable: items_query in /htdocs/mysite/portfolio/plog-includes/plog-functions.php on line 2103
    Fatal error: Call to a member function fetch_row() on a non-object in/htdocs/mysite/portfolio/plog-includes/plog-functions.php on line 2103

     

    I also get the same errors for line 2650.

     

    I also have one that is slightly different

    line 2931

     

    return mysql_result($numresult, 0, 'num_pictures');

     

    Would it be possible to show me how to insert  list($num_items) = $items_query->fetch_row();  into the function

  3. Hi, thank you for responding.

     

    Because I was not sure how to do the update to mysqli I found an online app MySQLConverterTool

    which did most of the update. However, it was not able to do the mysql_result(). I have looked at the

    original file and I don't think run_query() has been updated.

     

    I have searched and read a lot but still do not understand how to do this. From what I have read there

    is an object way and a procedural way. I am not sure but I don't think app is written the object way so

    is it possible to mix them?  

     

    Sorry for being so dumb but I am not sure how to insert what you have written into the function I posted.

  4. Hi, could someone please help me update this function. I have search and found many

    solutions but the problem is I am a novice at PHP and do not understand how to

    implement them.

     

    function plogger_init_collections($arr) {
    $sql = "SELECT COUNT(DISTINCT `parent_collection`) AS `num_items`
    FROM `".PLOGGER_TABLE_PREFIX."pictures`";
    $result = run_query($sql);
    $num_items = mysql_result($result, 0, 'num_items');
    $GLOBALS['total_pictures'] = $num_items;
     
    There several functions in this Plogger gallery application that uses
    mysql_result but I think if someone could show me a working example
    I could workout how to update the others.
     
    I hope I have included sufficient information and thanks in advance
    for any help.
  5. Hi,

     

    Sorry but I don't understand the example given. I am new to PHP and struggling quite a bit to get my head around this.

    Perhaps someone could be a little more patient with me offer some more help.

     

    To my original switch function, I added the following:

     

    case "galleries";

    include 'galleries.php';

    break;

     

    and us ?page=galleries&level=album&id=2 in a href to include the gallery page. This works ok and the gallery opens

    showing the correct images. However, if I try to navigate in the gallery using ?page=Galleries&level=album&id=10, or

    http://localhost/mysite/index.php?page=Galleries&level=album&id=10, from a link, I get directed back to the default

    home page.

     

    Is it possible to pass variables to the open gallery page to allow me to change the images shown in the gallery

    from a link. If this is not possible, could someone suggest another option - hopefully in a way I can understand.

     

    As for putting all my pages on one page. Tutorials I have read state that you can have an index page with a header file

    and a footer file and just change the content with includes which what I am trying to do. Is this wrong?

     

    Thanks in advance.

  6. Hi,

     

    I have a problem that I am not quite sure how to solve.

     

    I have a standard index.php page with header, footer and content area.

     

    I use a titorial found online to include six pages into the content area

    via a unordered list and a switch function.

     

    Sample code below:

     

    <ul class="topMenu">

    <li><a href="?page=home">HOME</a></li>

    <li><a href="?page=news">NEWS</a></li>

    </ul>

     

    <?PHP

    switch($page)

    {

    case "home";

    include 'home.php';

    break;

    case "news";

    include 'news.php';

    break;

    default;

    include 'home.php';

    break;

    }

    ?>

     

    This all works well. The problem occurs when I try to link to

    pages in an image galley with links like the following:

    http://localhost/mys...evel=album&id=2

     

    I don't know how or if it is possible to include my gallery pages

    in my navigation.

     

    Could someone please offer suggestions or sample scripts that

    would point me in the right direction.

     

    Also, is this a safe method to nagivate a site.

     

    Thanks in advance,

     

    Terrence

  7. Hi,

     

    Thanks everyone I finally got it working with the following:

     

    <?php

    echo '<a class="fancybox fancybox.iframe" href="'.$result->url.'?venue_name='.$id.'"</a>';

    ?>

     

    I am still very new to PHP so I am making a lot of mistakes.

     

    My database has well over 100 entries and growing so could someone please give me a pointer as to

    how I can include the url in the script instead of the database. Assuming that I posted enough code in

    my original post.

     

    Thanks again.

  8. Hi,

     

    I have tried many combinations of quote and concatenation but still getting an error. This is what I have at the

    moment but still getting errors.

     

    echo '<a class=\"fancybox fancybox.iframe\" href="'.$result->url.'?'venue_name=$id'"</a>';

     

    Could someone please help.

     

    Thanks again

  9. Hi,

     

    Could I get some help with a syntax error that I can't seem to find?

     

    The following is an original section from a script I found to create a live search:

     

    while ($result = $query ->fetch_object()) {

    if($result->cat_id != $catid) { // check if the category changed

    echo '<span class="category">'.$result->cat_name.'</span>';

    $catid = $result->cat_id;

    $id = $result->cat_id;

    }

    echo '<a class=\"fancybox fancybox.iframe\" href="'.$result->url.'"</a>';

    echo '<img width="40" height="40" src="images/all/'.$result->img.'" alt="" />';

     

    I need to be able to pass the value of id to the page opened by the fancybox, so I added the following:

    $id = $result->id; after line 5 ($id = $result->cat_id;) and, ?venue_name=$id as in the line below.

     

    echo '<a class=\"fancybox fancybox.iframe\" href=".$result->url.?venue_name=$id."</a>';

     

    This does not work because it gives venue_name the value $id and not the numeric value of $id.

    I have tried various combination of quotes as in the line below:

     

    echo '<a class=\"fancybox fancybox.iframe\" href="'.$result->url.'?'venue_name=$id'"</a>';

     

    but now I am getting syntax errors unexpected T_STRING, expecting ',' or ':'

     

    The url for the page is stored in the database (pop_up.php) but I would like to be able to include it in the

    script so I don't have to enter it multiple times in the database.

     

    Could someone please offer some advice.

     

    Thanks in advance.

  10. Hi,

     

    Thanks for the reply.

     

    While I was waiting for a reply, I had an idea which I tried and it worked. Not sure if it is the right but it works.

     

    I put the start of the <select> outside of the php like this:

    <form>

    <select name="genre" id="genre" onchange="selectGenre(this.value)" >

    <?php

     

    require_once '../includes/db_connect.php';

     

    $sql = "SELECT idgenre, genre_name

    FROM genre ORDER BY genre_name";

    $res = mysql_query($sql);

     

    echo "<option value='0'>select a genre</option>";

    while (list($id, $name) = mysql_fetch_row($res)) {

    echo "<option value='$id'> $name</option>";

    }

    echo "</select>\n";

     

    ?>

    </form>

     

    and everything works fine.

     

    Thanks again.

  11. Hi,

     

    Is it possible to call a javascript function from a php generated selection menu?

     

    I am trying to update a list of music venues based on the genre selected from a dropdown selection menu.

    A list member (Barand) was very kind and provided me with the following code to generate the menu from

    a database.

     

    <?php

    $sql = "SELECT idgenre, genre_name

            FROM genre ORDER BY genre_name";

    $res = mysql_query($sql);

     

    echo "<select name='genre' id='genre'>

        <option value='0'>- select genre -</option>";

    while (list($id, $name) = mysql_fetch_row($res)) {

        echo "<option value='$id'> $name</option>";

    }

    echo "</select>\n";

    ?> 

     

    In order to update the list without reloading the page I need to call a javascript function:

    onchange="selectGenre(this.value)"

     

    I have tried various version of the following:

    echo "<select name='genre' id='genre' <script type='text/javascript'>  onchange='selectGenre(this.value)' '</script>'

     

    and I  have searched many sites but have not found a solution that works. Maybe I am not entering the correct

    search term, so could someone please offer some suggestions.

     

    Thanks in advance.   

  12. Thanks Barand for your answer though I am not sure I fully understand.

     

    I think what you are saying is that I should create a table to give each genre an id and its name then

    link that to my search table by the same id number. I am not quite sure how to implement the 'cat_id' in

    the search table and the 'idcat' in category table. Since a venue can have multiple genres  (jazz, blues, latin...)

    do I need to create a separate field in my search table for each genre?

     

    Also from your sample code, it looks like you are generating a select genre menu, but I already have a

    menu in a form with the full list of genre options. Do I need to use PHP to create the menu?

     

    Thanks again.

  13. Hi,

     

    I have a mysql database of music venues and a PHP scripts to display all the venues

    in a div. The page also has a form with a select menu of music genres. What I would

    like to do is have the user choose a genre (jazz for example) from the select menu

    and have the div update without reloading the page to only show venues that play jazz.

     

    I searched and found a tutorial here: http://www.w3schools.com/php/php_ajax_database.asp

    but I am not sure how to convert it to work with my database as it appears the 'id' is

    required to get it to work and my database is not setup to do anything with the 'id'.

     

    I am not that familliar with databases and have stored my data in the following way:

    id:

    incremental

     

    Cat_id:

    can be 1, 2 or 3 depending on if the venue is a club, bar or live music venue

     

    Name:

    Venue Name

     

    Address:

    Venue Address

     

    img:

    c3.jpg

     

    Desc

    Music Played: Jazz, Blues, R&B, House etc., (will be different for each venue)

     

    Info:

    Detailed venue info

     

    url:

    Web Address

     

    Is it possible to use the 'desc' field as it is to perform the genre search?

     

    This is the PHP I am using to display the venues on the page:

     

    <?php

    require_once '../includes/db_connect.php';

     

    $result = mysql_query("SELECT * FROM search ORDER BY name");

    if (!$result) die ("Database access failed: " . mysql_error());

    $rows = mysql_num_rows($result);

    for ($i = 0 ; $i < $rows ; ++$i)

    {

    $img = mysql_result($result,$i,'img');

    $name = mysql_result($result,$i,'name');

    $address = mysql_result($result,$i,'address');

    $desc = mysql_result($result,$i,'desc');

    $info = mysql_result($result,$i,'info');

     

    if($i % 2 == 0) {

     

    echo "<div class='textBlock_club'>";

    }else{

    echo "<div class='textBlock2_club'>";

    }

    echo "<img width='95' height='95' src='../images/all/" .$img."' alt=$name />

    <p><span class=\"add_bold\">$name</span> <br />  <span class=\"add_colorClubs\">$address</span> <br /> $desc <br /> $info</p><a class=\"fancybox fancybox.iframe\" href=slide-div-test-2.html><div class=\"more\"><span class=\"more_color\">more info&#8230;</span></div></a></div>";

    }

    ?>

     

    Could I please either get some advice, links to tutorial sites or possible script examples?

     

    Thanks in advance.

     

  14. Hi,

     

    I am quite new to PHP so could someone please offer some advice as I am having problems writing the

    contents of a mysql database into a div.  My css is setup to style the content into 2 div's

    a light blue bg 'textBlock_club' and a darker blue bg textBlock2_club. The entire content should

    then be contained inside the div "venContent".

     

    At the the moment, only one item from the database is written into the div, the rest it seems

    is  being written into the body of the page.

     

    This is the code I am using.

     

    <div id="venContent">
    <?php
    require_once 'login.php';
    
    $db_server = mysql_connect($db_hostname, $db_username, $db_password);
    if (!$db_server) die("Unable to connect to MySQL: " . mysql_error());
    
    mysql_select_db($db_database)
    or die("Unable to select database: " . mysql_error());
    
    $result = mysql_query("SELECT * FROM search");
    if (!$result) die ("Database access failed: " . mysql_error());
    $rows = mysql_num_rows($result);
    for ($i = 0 ; $i < $rows ; ++$i)
    {
    $img = mysql_result($result,$i,'img');
    $name = mysql_result($result,$i,'name');
    $address = mysql_result($result,$i,'address');
    $desc = mysql_result($result,$i,'desc');
    $info = mysql_result($result,$i,'info');
    
    if($i % 2 == 0) { 
    
    echo "<div class='textBlock_club'>";
     }else{
     echo "<div class='textBlock2_club'>";
     } 
    echo "<img width='95' height='95' src=images/all/" .$img."' alt=$name />
    <p><span class=\"add_bold\">$name</span> <br />  <span class=\"add_colorClubs\">$address</span> <br /> $desc <br /> $info</p><a class=\"fancybox fancybox.iframe\" href=slide-div-test-2.html><div class=\"more\"><span class=\"more_color\">more info&#8230;</span></div></a></div>";
    echo "</div>";
    }
    ?>
    </div>
    

     

    I originally used an xml file to store the data and using the following code:

     

    <div id="venContents">
    	<?php
    	$xml = simplexml_load_file('all.xml');
    	$data = $xml->venue;
    
    	for ($i = 0; $i < sizeof($data); $i++) {
    	$images = $data[$i]->image;
    	$restname = $data[$i]->name;
    	$add = $data[$i]->address;
    	$desc = $data[$i]->description;
    	$inform = $data[$i]->info;
    
    	 if($i % 2 == 0) { 
    	echo "<div class='textBlock_club'>";
    	 }else{
    	 echo "<div class='textBlock2_club'>";
    	 }
    	echo "<a href=#.php><img src='" .$images . "'alt='name' /></a>
    	<p><span class=\"add_bold\">$restname</span> <br />  <span class=\"add_colorClubs\">$add</span> <br /> $desc <br /> $inform</p> <a class=\"fancybox fancybox.iframe\" href=#.php><div class=\"more\"><span class=\"more_color\">more info&#8230;</span></div></a>";
    	echo "</div>";
    	}
    
    	?>
    </div>
    

     

    everything formatted correctly.

     

    Could someone tell me where I am going wrong.

     

    Thanks in advance,

    James

     

     

     

×
×
  • 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.