Jump to content

Using mySql 5.0 functions with PHP


Recommended Posts

If mysql functions are not working then the mysql extension hasnt been loaded correctly.

Create a new php file called it info.php. now add the following code to the file:
[code=php:0]<?php
phpinfo();
?>[/code]

Upload to your website, now goto mysite.com/info.php

Scroll down the page, do you see a MySQL section at all. To find the MySQL section when running the phpinfo function search for [b]mysql Support[/b] or [b]mysqlI Support[/b]. If you find a section and its the mysqli section you'll need to use the mysql[b]i[/b] functions and not the standard mysql functions, or use the mysql functions if its the standard mysql extension thats enabled. if you find nothing then the mysql extension has been enabled.
Link to comment
Share on other sites

Thanks wildteen88 for your help. I use NuSphere Editor for see the [b]phpinfo.php [/b] without need to upload the file and I found this. (I understand according to your post that [b]mysql [/b] functions are enabled, right?)


                       mysql
MySQL Support                  enabled
Active Persistent Links              0 
Active Links                            0 
Client API version                 3.23.49 

Directive                          Local Value              Master Value
mysql.allow_persistent            On                           On
mysql.connect_timeout           60                           60
mysql.default_host              no value                   no value
mysql.default_password       no value                   no value
mysql.default_port              no value                   no value
mysql.default_socket           no value                  no value
mysql.default_user              no value                  no value
mysql.max_links                  Unlimited                 Unlimited
mysql.max_persistent          Unlimited                 Unlimited
mysql.trace_mode              Off                           Off

The code I use for try an example is this: (Really I'm absolutely new to PHP. Allways I work with ASP/ASP.NET)

[code]......more code.....

<?php

$con = mysql_connect("localhost", "root", "doremi");
mysql_select_db("jv");
$sql = "select id,tema,ritmo, archivo,fecha from temas order by tema";

$queryexe = mysql_query($sql);
  print($queryexe);
while(mysql_fetch_row($queryexe))
    {
  $id = mysql_result($queryexe, 1); //Puede ser $id= odbc_result($queryexe, "id");
  $tema = mysql_result($queryexe, 2); 
  $ritmo = mysql_result($queryexe, 3);
  $archivo = mysql_result($queryexe, 4);
  $fecha = mysql_result($queryexe, 5);
?>
    <tr>
    <td class="listas" bgcolor="#f7efde"> <?php print ("$tema"); ?></td>
    <td class="listas" bgcolor="#f7efde"> <?php print ("$ritmo"); ?></td>
    <td class="listas" bgcolor="#f7efde"> <?php print ("$archivo"); ?></td>
    <td class="listas" bgcolor="#f7efde"> <?php print ("$fecha"); ?></td>
    </tr>
<?php }?>

........more code.......[/code]

This code don't send any error but don't process nothing!

Thanks again for your time....
Link to comment
Share on other sites

The mysql extension is enabled then as you can see the mysql section when you run the phpinfo function.

The only problems i see with your code is this:
[code]while(mysql_fetch_row($queryexe))
    {
  $id = mysql_result($queryexe, 1); //Puede ser $id= odbc_result($queryexe, "id");
  $tema = mysql_result($queryexe, 2); 
  $ritmo = mysql_result($queryexe, 3);
  $archivo = mysql_result($queryexe, 4);
  $fecha = mysql_result($queryexe, 5);
?>
    <tr>
    <td class="listas" bgcolor="#f7efde"> <?php print ("$tema"); ?></td>
    <td class="listas" bgcolor="#f7efde"> <?php print ("$ritmo"); ?></td>
    <td class="listas" bgcolor="#f7efde"> <?php print ("$archivo"); ?></td>
    <td class="listas" bgcolor="#f7efde"> <?php print ("$fecha"); ?></td>
    </tr>
<?php }?>[/code]
Change the highlighted code above to this:
[code=php:0]while($row = mysql_fetch_row($queryexe))
{
?>
    <tr>
      <td class="listas" bgcolor="#f7efde"><?php print $row['tema']; ?></td>
      <td class="listas" bgcolor="#f7efde"><?php print $row['ritmo']; ?></td>
      <td class="listas" bgcolor="#f7efde"><?php print $row['archivo']; ?></td>
      <td class="listas" bgcolor="#f7efde"><?php print $row['$fecha']; ?></td>
    </tr>
<?php
}
?>[/code]
Do you get anything now?
Link to comment
Share on other sites

Thanks but unfortunately don't work. If, with the same code (changing the "Connect" tag to ODBC format), I change the [b]mySql functions [/b] by [b]odbc functions [/b] work. Otherwise, no. I do not know what happens. In my Web Server neither work but by another reason: I don't know how or what privileges I need to manage mySql and although I send the ticket to consult the problem, not yet have responded to me. 
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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