Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 23

Thread: Why wont this code work online.

  1. #11
    Join Date
    Jan 2004
    Posts
    2,011
    Rep Power
    0

    Default

    Quote Originally Posted by owen
    what you do is you call the function
    Code:
     echo mysql_error();
    after the
    Code:
    $result = mysql_query($query, $dblink);
    did you follow this instructions along with mine. this is basically the situation. based on your error the result that you pass to the mysql_fetch_row, has no value in it because the query failed. so your passing a null value, are you sure you followed my instructions. cuase
    PHP Code:

    $getdata 
    "SELECT * FROM meets WHERE pass LIKE '$pass'";


    if(
    $query mysql_query($getdata) ){
       echo 
    mysql_error();
    }
    else{
      echo 
    "query executed sucessfully <br />";
      
    $result mysql_fetch_row ($query//i'ld use assoc so its easier to reffer to the field names
      
    $rows mysql_num_rows($query);
      if(
    $rows 0){
        
      }
      else{
       echo 
    "query was successful but returned " $rows " results"
     }

    copy and paste that and tell me what happens?
    Last edited by death_knight; Jun 9, 2006 at 11:16 PM.

  2. #12
    Join Date
    Sep 2004
    Posts
    281
    Rep Power
    0

    Default

    Quote Originally Posted by death_knight
    if($$query = mysql_query($getdata) ){
    echo mysql_error();
    }
    Think there is a typo in the if statment.

    PHP Code:
    MySQL Example

    The most common database used with PHP is MySQL
    so I guess you should be familiar with the following codeIt connects to a MySQL server at localhostdatabase mydb, and executes an SQL select statementThe results are printedone line per row.

    $db mysql_connect("localhost""root""password");
    mysql_select_db("mydb",$db);
    $result mysql_query("SELECT * FROM employees",$db);
    if (
    $result === false) die("failed"); 
    while (
    $fields mysql_fetch_row($result)) {
     for (
    $i=0$max=sizeof($fields); $i $max$i++) {
            print 
    $fields[$i].' ';
     }
     print 
    "<br>\n";

    PHP Code:
    Here is the equivalent code in ADODB

     
    include("adodb.inc.php");
     
    $db NewADOConnection('mysql');
     
    $db->Connect("localhost""root""password""mydb");
     
    $result $db->Execute("SELECT * FROM employees");
     if (
    $result === false) die("failed");  
     while (!
    $result->EOF) {
        for (
    $i=0$max=$result->FieldCount(); $i $max$i++)
               print 
    $result->fields[$i].' ';
        
    $result->MoveNext();
        print 
    "<br>\n";
     } 
    check this link to know more
    http://phplens.com/lens/adodb/tute.htm

  3. #13
    Join Date
    Mar 2006
    Posts
    4
    Rep Power
    0

    Default

    ensure the database username and pass are the same on your server and development machine

  4. #14
    Join Date
    May 2004
    Posts
    530
    Rep Power
    0

    Default

    Thanks very much will try it out.

    By the way can this this work with windows iis server
    Last edited by Arch_Angel; Jun 17, 2006 at 04:33 PM. Reason: merged multiple posts
    "...men are that they might have joy."
    Nephi

  5. #15
    Join Date
    Jan 2004
    Posts
    2,011
    Rep Power
    0

    Default

    if php can run on an iss server then i dont see why not. question is you sure is a mysqldb you working with?

  6. #16
    Join Date
    May 2004
    Posts
    530
    Rep Power
    0

    Default

    yep. mysql 4.2 and php 4 +.
    "...men are that they might have joy."
    Nephi

  7. #17
    Join Date
    Jan 2004
    Posts
    2,011
    Rep Power
    0

    Default

    you dont really want help leo. POST YOUR ERROR MESSAGES or you already get it working? right now we're just guessing the possible problems and giving you advice based on that. however we cant know what exactly is wrong untill we see the error message geneated from mysql_error(). if you used my code above it should trigger an error if the query failed.

  8. #18
    Join Date
    May 2004
    Posts
    530
    Rep Power
    0

    Default

    I am sorry you. I guess i just gave up, because i still cant understand how it works on one machine and dont work an another. I will post results soon.
    "...men are that they might have joy."
    Nephi

  9. #19
    Join Date
    Apr 2004
    Posts
    4,811
    Rep Power
    0

    Default

    I dont really care much for the code, but u said u were using iis as ur localhost thingy.. but in the first line of ur post it looks like a linux server. No big deal, but uhmm, does ur hosting package give u access to mysql???

  10. #20
    Join Date
    May 2004
    Posts
    530
    Rep Power
    0

    Default

    yes it does. i have the abillty to create a user and give them rights.
    Last edited by leocrawf; Jun 26, 2006 at 05:00 PM.
    "...men are that they might have joy."
    Nephi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •