Jump to content

andy_b42

Members
  • Posts

    34
  • Joined

  • Last visited

    Never

Posts posted by andy_b42

  1. mysql_query("SELECT * EXCEPT field1, field2, etc FROM table WHERE);

     

    Correct me if i am wrong, but i believe adding in a WHERE clause requires that arguments be supplied, i think the code above would just error as soon as the database attempted to execute the query.

     

    gple, if you remove your where clause completely, youshould get back all of the results in the table e.g.

     

    mysql_query("select * from table")

  2. By the looks of it, there are 4 "{" in this section and only 3 "}", i suspect it has something to do with the line "if(mysql_num_rows($fixtures)==0) ", not really read through what your code is trying to do though

     

    <?php
    if (isset ($message))
    {
    echo($message);
    }
    else
    {
      echo('<form method="post" action="add_report.php">');
      echo('<table>');
       echo ('<tr><td><select name="match"><option>Please select Fixture</option>');
       $fixtures=mysql_query('SELECT * FROM `tbl_fixture_dates` INNER JOIN `tbl_fixtures` ON `tbl_fixture_dates`.`date_id` = `tbl_fixtures`.`date_id` WHERE `tbl_fixtures`.`team_id` =  \'' . $_GET['team_id'] . '\' order by match_date');
    if(mysql_num_rows($fixtures)==0) 
    echo('<option>there is no data in table..</option>');
    else
    {
    while($matchrow=mysql_fetch_assoc($fixtures))
    {
    echo "<option value=".$matchrow[match_id].">".date("d-M-Y", strtotime($matchrow[Date]))."|".$matchrow[Opposition]."</option>";
    }
    }
    echo ('</select></td></tr>');
    echo('<tr><td><input name="title" type="text" value="Enter Headline Here..." size="70" class="button"/></td></tr>');
    echo ('<tr><td>');
      $oFCKeditor = new FCKeditor('fcktext'); 
      $oFCKeditor->BasePath = "includes/fckeditor/"; 
      $oFCKeditor->Value    = ""; 
      $oFCKeditor->Width    = 540; 
      $oFCKeditor->Height   = 400; 
      echo $oFCKeditor->CreateHtml(); 
    echo ('</td></tr>');
    echo ('<br /> ');
    echo('<tr><td><input type="hidden" name="submit_form" value="1" /> </td></tr>
    <tr><td><input type="submit" value="Save Post" class="button"/> </td></tr>
    </table>
    </form>');
    ?>

  3. Solved, i was joining my tables on the table name and not the constraint name (which is where i should have been joining).

     

    Incase this is of use to anyone:

     

    SELECT  
        kcu.COLUMN_NAME 
    FROM  
        INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc 
        INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu ON tc.CONSTRAINT_NAME = kcu.CONSTRAINT_NAME  
    WHERE 
        tc.CONSTRAINT_TYPE = 'PRIMARY KEY'  
        AND tc.TABLE_NAME = 'table1'
    

  4. I've been looking how to find the Primary Key of a table similar to the mysql equivalent of something like

     

    show keys from table1 where Key_name = 'primary'

     

    So far i have got this stage:

     

    SELECT
    kcu.COLUMN_NAME
    FROM
    INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu
    INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc on kcu.TABLE_NAME = tc.TABLE_NAME
    WHERE
    tc.CONSTRAINT_TYPE = 'PRIMARY KEY'
    AND kcu.TABLE_NAME = 'table1'
    

     

    However, if the table contains a Foreign Key field that is a Primary Key on a nother table, it returns it in the query.

     

    Does any one know of a way to return ONLY the Primary Key of a table and nothing else?

     

    Thanks

  5. Im not familiar with fusionchart, but if you are wanting to write the contents of the query result to an XML file, you can use the XMLwriter classes, but i prefer for smaller xml files to just output a file formatted as XML as though i were making a text.

     

    <?php
       $xml = "<?xml version = '1.0' encoding = 'UTF-8'?>\n";
       $xml .= "<container>\n";
       $xml .= "\t<parent name=\"some value\">\n";
       $xml .= "\t\t<child variable=\"some value\">\n";
       $xml .= "\t\t<child variable=\"some value\">\n";
       $xml .= "\t</parent>\n";
       $xml .= "\t<parent name=\"some value\">\n";
       $xml .= "\t\t<child variable=\"some value\">\n";
       $xml .= "\t\t<child variable=\"some value\">\n";
       $xml .= "\t</parent>\n";
       $xml .= "</container>\n";
    
       $openFileToWrite = fopen("myXML.xml", "w");
       fwrite ($openFileToWrite, $xml);
       fclose ($openFileToWrite);
    ?>
    

     

    Very quick and very dirty, but it works. If your xml files are going to be quite big or you are using this sort of thing a lot, you should consider looking into the appropriate classes designed for writing xml files as this method can quickly become a pain to deal with.

  6. When you do your join, you need to say on what field the tables join.

     

    So your join will be something like:

     

          SELECT
             o.oHOUSE,o.oWILL,o.oRENTED,o.oIMAGE,o.oUPGRADES,o.oID,o.oOWNER
          FROM
             `house_owned` `o`
          LEFT JOIN
             `house_rentals` `r` on r.rOWNER = o.OWNER
    

     

    I am not fully sure i understand what you are trying to achieve, but really you should specify how the tables are linked in a join.

  7. Only other thing i can think of then if you have 777 permissions on that folder and file would be that the directory is correct.

     

    Have you tried using getcwd() to check you are in the right place?

  8. Permissions think is allright, I can upload files with no problem.

     

    Paths, Ive tried change several times and no result, nothing work.

     

    Having access rights to create files doesn't neccesarily mean you will be able to delete them.

  9. You should be able to do this by terminating each query with a ";"

     

    eg

    $query = "
       UPDATE secondary_table SET amount = '$newsec_amt' WHERE membersemail = '$recipient';
       UPDATE primary_table SET amount = '$newsender_amt' WHERE membersemail = '$sender';";
    
    mysql_query($query);

     

    This will execute both queries.

     

    If what you want to do is join both queries into a single string, you can do this, but i would recommend against it because it will confuse things quite significantly. You would need to specify which table each field is on (primary_table.field etc) and you would still have to specify that you were changing each individual field on each table. You can't do something like:

     

    "update table1, table2 set field1 = 'value' where table1.field2 = x and table2.field = y"

     

    because the sql server wont know which tables you are referring to.

  10. I made this file to return an image from a database (i use this with an mssql database, so ive just chagned the commands from mssql_ to mysql_, i think it should work the same.

     

    Just amend the query and connection string for your own settings and it should work

     

    <?php
    session_start();
    
    if($_SESSION['loggedIn']){
    
    	require("settings.php");
    
    	$imageID = $_GET['imageID'];
    
    	$connection = mysql_connect($server, $username, $password)
    		or die ("Unable to connect to server");
    
    	$db = mysql_select_db($database, $connection)
    		or die ("Unable to select database");
    
    	$sqlString1 = "SELECT image FROM images WHERE imageID = $imageID";
    
    	$sqlResult1 = mysql_query($sqlString1, $connection) 
    		or die ("Unable to run query. Error ID 1!");
    
    	$row = mysql_fetch_assoc($sqlResult1);
    
    	$imagebytes = $row['image'];
    
    	header("Content-type: image/jpeg");
    
    	print $imagebytes;
    }
    ?>

  11. This line:

     

    GetSQLValueString($_SESSION['MM_Username'], "text")

     

    calls a function (GetSQLValueString), but i can't see it being defined anywhere in your code below, it may be in one of your included files, but the error you are getting suggests that you have not made that function visible to the page in your second piece of code

  12. alin19,

     

    A few things i would check would be that your setup accepts <? instead of <?php (i doubt this would make any difference but i would check anyway)

     

    Next, i would check that HTTP_SERVER_BASE ends with a "/".

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