Getting data with PHP from Mysql database error -
i send data mysql database php page.
the server have script classify file has been uploaded before php comes action, server enters data database.
the php script should show data (the column interesting data it's called "cond"). code following:
$uploaddir = '/opt/lampp/htdocs/u'; $uploadfile = $uploaddir . basename($_files['userfile']['name']); $link = mysql_connect("localhost", "pepito", "dominguez"); $nombre=basename($_files['userfile']['name']); $tamany=basename($_files['userfile']['size']); $sql="insert `wordpress`.`uploads` (`autoinc`, `nombre`, `tamany`,`fecha`) values (null, '$nombre', '$tamany', current_timestamp)"; $sqls="select `cond` `cm` `id`='$numero'"; if (move_uploaded_file($_files['userfile']['tmp_name'], $uploadfile)) { // echo "file valid , it's uploaded"; mysql_select_db('wordpress'); mysql_query($sql); $numero=mysql_insert_id(); $condicion=0; sleep(3); $condicion= mysql_query($sqls); $a = $condicion + 1; echo "$a"; echo "$numero";
what should in te echo "$a" number between 0 2, random number changes everytime file uploaded.
i have tried 'id' column instead 'cond' column , same.
extra data: i'm using wordpress, , plugin called "allow-php-in-posts-and-pages". other echo in code works properly.
you need fetch result after executing query. should have use $numero
once set, move $sqls
conditional after insert.
http://php.net/manual/en/function.mysql-query.php
mysql_select_db('wordpress'); mysql_query($sql); $numero=mysql_insert_id(); $sqls= "select `cond` `cm` `id`='$numero'"; $result = mysql_query($sqls); if (!$result) { $message = 'invalid query: ' . mysql_error() . "\n"; $message .= 'whole query: ' . $query; die($message); } $row = mysql_fetch_assoc($result); $condicion = $row['cond'];
you should switch on mysql_ driver mysqli_ or pdo, php pdo , mysqli.
Comments
Post a Comment