Jump to content

icue

Members
  • Posts

    20
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

icue's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, Thank you for responding. I changed it back to the function you gave me and passed $comment_result as the variable and it worked. I have one other error but I will have a go at solving it myself before asking for more help. Thanks again.
  2. Sorry I just noticed after posting that I had changed the function name to soda_mysqli_result so as not to get confused. Although it does not show in my post I have also changed it in the function example supplied.
  3. 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.
  4. Thank you all for your help. I will try mac_gyver's suggestion first as this app have many long php files. I will have to attempt it tomorrow as it's the early hours of the morning here. Hope I can get it working but if I can I hope I will be able to get some more help. Thanks again.
  5. 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
  6. 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.
  7. 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.
  8. 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.
  9. Hi, thanks for replying. I am just starting to learn php so I am not sure how to dynamically build the url. Could you perhaps give a short example. Thanks, Terrence
  10. 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
  11. 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.
  12. 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
  13. 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.
  14. 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.
  15. 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.
×
×
  • 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.