Jump to content

At my wits end with this white screen.


bruceybonus
 Share

Recommended Posts

Hello! Incredibly new to PHP, so if this problem is a clear error i apologise. I am developing a page which will display a product based on what is clicked as a result of a search, my problem is that no matter that happens I cannot display anything from the Products table in my database:

 

<?php
session_start();
include "connect.php";



$prodsql="SELECT product_ID, product_Name, Category, Price, Information from Product ;";
$prodresult = mysqli_query($_SESSION['conn'], $prodsql);

while ($prow = mysql_fetch_array($prodresult, MYSQL_NUM)) {
echo "<p> $prow['product_Name']";

}
else{

}

 

What am i missing? The connect.php works as I can successfully login and register members.

 

Thank you

Link to comment
Share on other sites

Sorry guys wrong file and couldn't find the edit

 

<?php
session_start();
include "connect.php";

if (isset($_GET['id'])){

$data = $_GET['id'];
$prodresult = mysql_query("SELECT product_ID, product_Name, Category, Price, Information from product");

while ($prow = mysql_fetch_array($prodresult, MYSQL_NUM)) {
echo "<p> $prow['product_Name']";

}
else{

}

Link to comment
Share on other sites

Thank you for the reply! I have tinkered a little:

 

<?php
session_start();
include "connect.php";


if (isset($_GET['id'])){

$product_id = $_GET['id'];
$productquery="SELECT product_Name, Category, Price FROM product WHERE product_ID= $product_id";
$prodresult = mysqli_query($productquery);
while ($row =  mysqli_fetch_array($prodresult, MYSQL_NUM)){
echo "<div><p>Name: $row[0]</p><p>Category: $row[1]</p><p>Price: $row[2]</p></div>";
}
echo "<div><a href=\"cart.php?action=add&product=$product_id\">add to basket</a></div>";
echo "fail";
}

mysqli_close($_SESSION['conn']); //close database connection

?>

 

I now see the link to add to the basket.

 

I am also having problem with a page showing every product:

 

$prosql="SELECT product_ID, product_Name, Category, Price, Information FROM product";
  $proresult=mysqli_query($_SESSION['conn'], $prosql);

      $productcount = mysql_num_rows($proresult); // count the output amount

      if ($productcount != 0) {

 

The above sql is coming back with a result of 0 every time? I'm at a massive brick wall.

Link to comment
Share on other sites

You can't mix mysql_* extension functions with mysqli_* extension functions. Pick one or the other.

 

You should be developing with the following directives in your php.ini file. Find the directives, edit their values then restart Apache.

error_reporting = -1

display_errors = On

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

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