473,320 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Calling a function inside another function doesn't seem to work anymore with mysqli

2
Hi all,

Need enlightenment about the following:
I'm trying to adapt my php pages to mysqli. Everything seems to work after a few minor changes except a number of functions (as far as I can tell it's the ones where a function is called inside another function or where the same function is called again at the end of itself: I'll stick to the first problem for now).

The setup is this: I have a separate php page with a bunch of functions (called "functies.php") which is included in most pages with
Expand|Select|Wrap|Line Numbers
  1. include("functies.php");
In it there's a function called "songschrijver" which in turn uses two other functions ("herschiknaam" and "herschiknaam2") which are defined in the same "functies.php" page.

This is the code for "songschrijver":
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. function songschrijver($songid){
  3.     $resultaat = mysqli_query($con, "SELECT Auteur_ID, Uitvoerder FROM songs_met_auteurs, uitvoerders_zonder_instr
  4.      WHERE Auteur_ID = uitvoerders_zonder_instr.ID 
  5.      AND Song_ID =" . $songid . "
  6.      ORDER BY Uitvoerder");
  7.      $rij = mysqli_fetch_array($resultaat);
  8.  
  9.      if (mysqli_num_rows($resultaat) > 1){
  10.         if (mysqli_num_rows($resultaat) == 2){ ?>
  11.             <a href="resultaten_per_auteur.php?nummer= <?php echo $rij['Auteur_ID']; ?>">
  12.             <?php herschiknaam2($rij['Uitvoerder']); ?></a>
  13.             <?php $rij = mysqli_fetch_array($resultaat);
  14.             print " & "; ?>
  15.             <a href="resultaten_per_auteur.php?nummer= <?php echo $rij['Auteur_ID']; ?>">
  16.             <?php herschiknaam2($rij['Uitvoerder']); ?></a>
  17.             <?php
  18.         }
  19.         else{ ?>
  20.             <a href="resultaten_per_auteur.php?nummer= <?php echo $rij['Auteur_ID']; ?>">
  21.             <?php herschiknaam2($rij['Uitvoerder']); ?></a>
  22.                 <?php $rij = mysqli_fetch_array($resultaat);
  23.                 while ($rij){
  24.                     print ", "; ?>
  25.                     <a href="resultaten_per_auteur.php?nummer= <?php echo $rij['Auteur_ID']; ?>">
  26.                     <?php herschiknaam2($rij['Uitvoerder']); ?></a>
  27.                 <?php $rij = mysqli_fetch_array($resultaat);
  28.                 }
  29.             }
  30.     }
  31.     else{ ?>
  32.         <a href="resultaten_per_auteur.php?nummer= <?php echo $rij['Auteur_ID']; ?>">
  33.             <?php herschiknaam($rij['Uitvoerder']); ?></a><?php
  34.     }
  35. }
  36. ?>
It is used to display the names of songwriters in a cd track list. As for the other functions, "herschiknaam" turns "Lennon, John" into "John Lennon" and "herschiknaam2" turns the same into "Lennon". "songschrijver" checks how many authors a song has and then uses the other functions to display e.g. "John Lennon", "Lennon & McCartney" or "Harrison, Lennon, McCartney, Starr".

This worked perfectly with the mysql formulae (e.g. mysql_query, mysql_fetch_array, etc.) but doesn't anymore with mysqli (mysqli_query, etc.). When before it would display "Yesterday (Lennon & McCartney)", the same page now says "Yesterday ()". Is this something to do with calling functions inside functions?

Any help would be much appreciated.
Sep 4 '14 #1

✓ answered by guy13

Got the solution via different channel: forgot to define $con in the function. Doing this completely solved this and the other problem I mentioned.

1 1407
guy13
2
Got the solution via different channel: forgot to define $con in the function. Doing this completely solved this and the other problem I mentioned.
Sep 4 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

20
by: spasmous | last post by:
main() { float * f; initialize_f(f); // ...use f for processing free(f); }
1
by: Lopamudra | last post by:
Hi, I have implemented a HTTPHandler named ThumbnailGenerator.ashx to generate thumbnails for images. I have referenced this within my aspx file in the ImageUrl property of the Img control. When I...
3
by: Zongjun Qi | last post by:
Hey, In the book <Effective C++>, the author provides an example to prove why we need "pass by reference". I redoed the example, and found something interesting. The codes are:...
10
by: rockdc1981 | last post by:
Private Sub SupplierSKUCode_AfterUpdate() If Nz(DLookup("SupplierSKUCode", "tblProduct", "SupplierSKUCode='" & _ Me.SupplierSKUCode & "'"), "zzzz") <> "zzzz" Then MsgBox...
2
by: Mark Cooney | last post by:
Hi Why doesnt this work? <% CatID = dsMain.SelectParameters("fkCatID").ToString%> or <% CatID = Eval("fkCatID") %> Anyone have a solution?
1
by: newbie | last post by:
This is a snippet from C++ FAQs, which I have never done--- when I do such a thing, I would declare function used by constructor ( in this example, init() ) as static. But I do understand that it...
4
by: MasterVision | last post by:
Hey folks, I have .NET Solution with the combinations of VB, C/C++ and C# projects on it. I have no problem calling C/C++ function inside my VB project but I dont know how to do the same with C#...
20
oll3i
by: oll3i | last post by:
how do i add a function i want to use inside another js function belonging to js class ?
4
by: supriyamk | last post by:
Hi, i am trying to copy files of a certain type into a different directory using perl, The copy function doesnt seem to work. my @dir_list; my $sub_dir; my $file_name1; ...
2
by: panos100m | last post by:
Hi on page load a javascript functions (timedCount()) is executed (timer) which executes another javascript function (ajax function:findprov(divtowrite) ) in turn this calls a php file to query a...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.