php - query was empty error and I can't work out why -


i'm starting build simple product display system, build own skills, use on website work.

list.php

<html> <head> <title>retrieve data database</title> <?php $username=''; $password=''; $database=''; ?> </head> <body>  <ul>  <?php // connect database server mysql_connect(localhost,$username,$password);    // select database @mysql_select_db($database) or die( 'unable select database');    // sql query $sql = "select * products category = 30";  // execute query (the recordset $rs contains result) $result = mysql_query($sql);  // loop recordset $rs while($row = mysql_fetch_array($result)) {     // name of person   $strname = $row['make'];          // create link person.php id-value in url    $strlink = "<a href = 'product.php?id = " . $row['id'] . "'>" . $strname . "</a>";      // list link    echo "<li>" . $strlink . "</li>";    }  // close database connection mysql_close(); ?>  </ul> </body> </html> 

product.php

<html> <head> <title>retrieve data database</title> </head> <body>  <?php  $username=""; $password=""; $database=""; // connect database server mysql_connect(localhost,$username,$password);    // select database @mysql_select_db($database) or die( "unable select database"); // data database depending on value of id in url $sql = mysql_query('select * products id=' . $_get["id"]);  $result = mysql_query($sql);   if(!$result)     die(mysql_error());  // loop recordset  while($row = mysql_fetch_array($result)) {      // write data of product     echo $row['category'];     echo "<p>";     echo $row["make"];     echo "<p>";     echo $row["description"];     echo "<p>";     echo $row["picture"]; }  // close database connection mysql_close(); ?>  <p><a href="list.php">return list</a></p>  </body>  </html> 

can seen messing here

if can working me i'd grateful!

try way, not sure stubborn issue. can try changing case of keys of $_get array lowercase using array_change_key_case()

$get = array_change_key_case($_get); $id = $get['id'];  $sql = mysql_query('select * products id=' . $id); 

nb: make first sure select * products id=your_row_id return results or not?


Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -