| 
	
 | 
 Posted by Pedro Graca on 11/17/06 15:17 
casper christensen wrote: 
> There is no bug! 
 
LOL, why doesn't it work then? 
Do you call the reason for the non-functioning a "feature"? 
 
> I need to know how to fetch the created Id. The must be some "standard" 
> code to get "load" values from the database. 
 
Try this: 
 
    <?php 
    define('DB_HOST', '127.0.0.1'); ### change 
    define('DB_USER', 'nonroot');   ### these 
    define('DB_PASS', 'password');  ### define's 
    define('DB_DATA', 'example');   ### to match 
    define('YOURTABLE', 'data');    ### your configuration 
    define('TESTTABLE', 'test'); 
 
    $conn = mysql_connect(DB_HOST, DB_USER, DB_PASS) 
          or die('Connection error.'); 
    if (!mysql_select_db(DB_DATA)) die('Database error.'); 
    $sql = "create table " . TESTTABLE . 
          " (test_id int not null primary key auto_increment," . 
          " test_val int)"; 
    if (!mysql_query($sql)) die('Create table failed.'); 
    $sql = "insert into " . TESTTABLE . " (test_val) values (42)"; 
    if (!mysql_query($sql)) die('Insert failed'); 
    echo 'Last id created was: ' . mysql_insert_id() . "<br>\n";  
    mysql_close($conn); 
    ?> 
 
 
--  
I (almost) never check the dodgeit address. 
If you *really* need to mail me, use the address in the Reply-To 
header with a message in *plain* *text* *without* *attachments*.
 
[Back to original message] 
 |