Jump to content

paulbray

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Posts posted by paulbray

  1. ok sorry for multiple threads,  I have removed @ signs and this is the output

     

    Warning: mysqli_error() expects exactly 1 parameter, 0 given in /websites/123reg/LinuxPackage21/co/ns/ol/console-entertainment.co.uk/public_html/Test/view_products.php on line 60

     

    Notice: MySQLi Error: in /websites/123reg/LinuxPackage21/co/ns/ol/console-entertainment.co.uk/public_html/Test/view_products.php on line 60

    SKU_ProductID SKU_MerchSKUID Game_Title Platform Genre Weight Supplier Supplier_Price Cashback Cashback_Amount

     

    Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /websites/123reg/LinuxPackage21/co/ns/ol/console-entertainment.co.uk/public_html/Test/view_products.php on line 81

     

    Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in /websites/123reg/LinuxPackage21/co/ns/ol/console-entertainment.co.uk/public_html/Test/view_products.php on line 103

     

     

     

    Warning: mysqli_error() [function.mysqli-error]: Couldn't fetch mysqli in /websites/123reg/LinuxPackage21/co/ns/ol/console-entertainment.co.uk/public_html/Test/view_products.php on line 141

     

    My current coding

     

    <?php # View products
    
    $page_title = 'View Inventory';
    
    require_once ('connect.php');
    
    $display = 35; // Number of records per page
    
    if (isset($_GET['p']) && is_numeric($_GET['p'])) { // How many pages there are
    
    $pages = $_GET['p'];
    
    } else {
    
    // Count number of records
    
    $q = "SELECT COUNT(Game_Title) FROM Products";
    
    $r = mysqli_query ($dbc, $q);
    
    $row = mysqli_fetch_array ($r, MYSQLI_NUM);
    
    $records = $row[0];
    
    // Calculate number of pages
    
    if ($records > $display) {// More than one page
    
    $pages = ceil ($records/$display);
    
    } else {
    
    $pages = 1;
    
    }
    
    } // End of p IF
    
    if (isset($_GET['s']) && is_numeric ($_GET['s'])) {
    
    $start = $_GET['s'];
    
    } else {
    
    $start = 0;
    }
    
    //make query
    
    $q = "SELECT SKU_ProductID, SKU_MerchSKUID, Game_Title, Platform, Genre, Weight, Supplier, Supplier_Price, Cashback, Cashback_Amount AS dr, FROM Products ORDER BY Game_Title ASC LIMIT $start, $display";
    
    $r = mysqli_query($dbc, $q) or trigger_error('MySQLi Error: ' . mysqli_error());
    
    
    echo '<TABLE ALIGN="CENTER" cellspacing="0" cellpadding="5" width="75%">
    
    <TR>
    <TD align="left"><b>SKU_ProductID</b></td>
    <TD align="left"><b>SKU_MerchSKUID</b></td>
    <TD align="left"><b>Game_Title</b></td>
    <TD align="left"><b>Platform</b></td>
    <TD align="left"><b>Genre</b></td>
    <TD align="left"><b>Weight</b></td>
    <TD align="left"><b>Supplier</b></td>
    <TD align="left"><b>Supplier_Price</b></td>
    <TD align="left"><b>Cashback</b></td>
    <TD align="left"><b>Cashback_Amount</b></td>
    </TR>
    ';
    
    $bg = '#eeeeee';
    
    while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
    
    $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); // Switch background color
    
    echo ' <tr bgcolor="' . $bg . '">
    
    <td align="left">' . $row['SKU_ProductID'] . '</td>
    <td align="left">' . $row['SKU_MerchSKUID'] . '</td>
    <td align="left">' . $row['Game_Title'] . '</td>
    <td align="left">' . $row['Platform'] . '</td>
    <td align="left">' . $row['Genre'] . '</td>
    <td align="left">' . $row['Weight'] . '</td>
    <td align="left">' . $row['Supplier'] . '</td>
    <td align="left">' . $row['Supplier_Price'] . '</td>
    <td align="left">' . $row['Cashback'] . '</td>
    <td align="left">' . $row['Cashback_Amount'] . '</td>
    </tr>
    ';
    }
    
    echo '</table>';
    
    mysqli_free_result ($r);
    
    mysqli_close($dbc);
    
    if ($pages > 1) {
    
    echo '<br /><p>';
    
    $current_page = ($start/$display) + 1;
    
    if ($current_page != 1) {
    
    echo '<a href="view_products.php"?s=' . ($start - $display) . '&p=' . $pages . ' ">Previous</a> ';
    
    for ($i = 1; $i <= $pages; $i++) {
    
    	if ($i != $current_page) {
    
    		echo '<a href="view_products.php"?s=' . (($display * ($i - 1))) . '&p=' . $pages . '"> ' , $i . '</a> ';
    
    	} else {
    
    		echo $i . ' ';
    
    	}
    
    }
    
    if ($current_page != $pages) {
    
    	echo '<a href="view_products.php"?s=' . ($start + $display) . '&p=' . $pages . '">Next</a>';
    
    }
    
    echo '</p>';
    
    }}
    ?>

     

     

  2. Hi,

     

    If anyone can assist I am receiving these errors

     

    Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /websites/123reg/LinuxPackage21/co/ns/ol/console-entertainment.co.uk/public_html/Test/view_products.php on line 80

     

    Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in /websites/123reg/LinuxPackage21/co/ns/ol/console-entertainment.co.uk/public_html/Test/view_products.php on line 102

     

    My Code is

     

    <?php # View products
    
    $page_title = 'View Inventory';
    
    require_once ('connect.php');
    
    $display = 35; // Number of records per page
    
    if (isset($_GET['p']) && is_numeric($_GET['p'])) { // How many pages there are
    
    $pages = $_GET['p'];
    
    } else {
    
    // Count number of records
    
    $q = "SELECT COUNT(Game_Title) FROM Products";
    
    $r = @mysqli_query ($dbc, $q);
    
    $row = @mysqli_fetch_array ($r, MYSQLI_NUM);
    
    $records = $row[0];
    
    // Calculate number of pages
    
    if ($records > $display) {// More than one page
    
    $pages = ceil ($records/$display);
    
    } else {
    
    $pages = 1;
    
    }
    
    } // End of p IF
    
    if (isset($_GET['s']) && is_numeric ($_GET['s'])) {
    
    $start = $_GET['s'];
    
    } else {
    
    $start = 0;
    }
    
    //make query
    
    $q = "SELECT SKU_ProductID, SKU_MerchSKUID, Game_Title, Platform, Genre, Weight, Supplier, Supplier_Price, Cashback, Cashback_Amount AS dr, FROM Products ORDER BY Game_Title ASC LIMIT $start, $display";
    
    $r = @mysqli_query ($dbc,$q);
    
    echo '<TABLE ALIGN="CENTER" cellspacing="0" cellpadding="5" width="75%">
    
    <TR>
    <TD align="left"><b>SKU_ProductID</b></td>
    <TD align="left"><b>SKU_MerchSKUID</b></td>
    <TD align="left"><b>Game_Title</b></td>
    <TD align="left"><b>Platform</b></td>
    <TD align="left"><b>Genre</b></td>
    <TD align="left"><b>Weight</b></td>
    <TD align="left"><b>Supplier</b></td>
    <TD align="left"><b>Supplier_Price</b></td>
    <TD align="left"><b>Cashback</b></td>
    <TD align="left"><b>Cashback_Amount</b></td>
    </TR>
    ';
    
    $bg = '#eeeeee';
    
    while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
    
    $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); // Switch background color
    
    echo ' <tr bgcolor="' . $bg . '">
    
    <td align="left">' . $row['SKU_ProductID'] . '</td>
    <td align="left">' . $row['SKU_MerchSKUID'] . '</td>
    <td align="left">' . $row['Game_Title'] . '</td>
    <td align="left">' . $row['Platform'] . '</td>
    <td align="left">' . $row['Genre'] . '</td>
    <td align="left">' . $row['Weight'] . '</td>
    <td align="left">' . $row['Supplier'] . '</td>
    <td align="left">' . $row['Supplier_Price'] . '</td>
    <td align="left">' . $row['Cashback'] . '</td>
    <td align="left">' . $row['Cashback_Amount'] . '</td>
    </tr>
    ';
    }
    
    echo '</table>';
    
    mysqli_free_result ($r);
    
    mysqli_close($dbc);
    
    if ($pages > 1) {
    
    echo '<br /><p>';
    
    $current_page = ($start/$display) + 1;
    
    if ($current_page != 1) {
    
    echo '<a href="view_products.php"?s=' . ($start - $display) . '&p=' . $pages . ' ">Previous</a> ';
    
    for ($i = 1; $i <= $pages; $i++) {
    
    	if ($i != $current_page) {
    
    		echo '<a href="view_products.php"?s=' . (($display * ($i - 1))) . '&p=' . $pages . '"> ' , $i . '</a> ';
    
    	} else {
    
    		echo $i . ' ';
    
    	}
    
    }
    
    if ($current_page != $pages) {
    
    	echo '<a href="view_products.php"?s=' . ($start + $display) . '&p=' . $pages . '">Next</a>';
    
    }
    
    echo '</p>';
    
    }}
    ?>

  3. I am trying to set up a item entry page form.png:thumb_17734.png

     

    Upon submission it shows unsuccessful even though I have checked the fields on mysql table and seem to be good am I missing something?

     

    <form action="" method="post" enctype="multipart/form-data" name="Product_Entry">
    <TABLE>
    <TR>
    <TD>Product ID</TD><TD><input name="SKU_ProductID" value="<?php if (isset($_post['SKU_ProductID'])) echo $_POST['SKU_ProductID']; ?>" type="text" size="11" maxlength="11" /></TD>
    </TR>
    <TR>
    <TD>Merchant SKU ID</TD><TD><input name="SKU_MerchSKUID" value="<?php if (isset($_post['SKU_MerchSKUID'])) echo $_POST['SKU_MerchSKUID']; ?>" type="text" size="18" maxlength="30" /></TD>
    </TR>
    <TR>
    <TD>Game Title</TD><TD><input name="Game_Title" value="<?php if (isset($_post['Game_Title'])) echo $_POST['Game_Title']; ?>" type="text" size="40" maxlength="40" /></TD>
    </TR>
    <TR>
    <TD>Platform</TD><TD><input name="Platform" value="<?php if (isset($_post['Platform'])) echo $_POST['Platform']; ?>" type="text" size="20" maxlength="20" /></TD>
    </TR>
    <TR>
    <TD>Genre</TD><TD><input name="Genre" value="<?php if (isset($_post['Genre'])) echo $_POST['Genre']; ?>" type="text" size="11" maxlength="11" /></TD>
    </TR>
    <TR>
    <TD>Weight</TD><TD><input name="Weight" value="<?php if (isset($_post['Weight'])) echo $_POST['Weight']; ?>" type="text" size="7" maxlength="7" /></TD>
    </TR>
    <TR>
    <TD>Supplier</TD><TD><input name="Supplier" Value="<?php if (isset($_post['Supplier'])) echo $_POST['Supplier']; ?>" type="text" size="25" maxlength="25" /></TD>
    </TR>
    <TR>
    <TD>Suppliers Price</TD><TD><input name="Supplier_Price" value="<?php if (isset($_post['Supplier_Price'])) echo $_POST['Supplier_Price']; ?>" type="text" size="10" maxlength="12" /></TD>
    </TR>
    <TR>
    <TD>Cashback</TD><TD><input name="Cashback" value="<?php if (isset($_post['Cashback'])) echo $_POST['Cashback']; ?>" type="text" size="6" maxlength="8" /></TD>
    </TR>
    <TR>
    <TD>Cashback Amount</TD><TD><input name="Cashback_Amount" value="<?php if (isset($_post['Cashback_Amount'])) echo $_POST['Cashback_Amount']; ?>" type="text" size="7" maxlength="11" /></TD>
    </TR>
    <TR>
    <TD><input type="hidden" name="submitted" value="true"/></TD><TD><input name="Submit" type="submit" value="Add_Product" /></TD>
    </TR></form></TABLE>
    
    <?php # Product Entry
    
    $page_title = 'Product Entry';
    
    if (isset($_POST['Submit'])) {
    
    $errors = array();
    
    if (empty($_POST['SKU_ProductID'])) {
    	$errors[] = 'Please enter Product ID.';
    } else {
    	$sid = trim($_POST['SKU_ProductID']);
    }
    
    if (empty($_POST['SKU_MerchSKUID'])) {
    	$errors[] = 'Please enter Merchant SKU.';
    } else {
    	$mid = trim($_POST['SKU_MerchSKUID']);
    }
    
    if (empty($_POST['Game_Title'])) {
    	$errors[] = 'Please enter Game Title.';
    } else {
    	$gt = trim($_POST['Game_Title']);
    }
    
    if (empty($_POST['Platform'])) {
    	$errors[] = 'Please enter Platform.';
    } else {
    	$pl = trim($_POST['Platform']);
    }
    
    if (empty($_POST['Genre'])) {
    	$errors[] = 'Please enter Genre.';
    } else {
    	$ge = trim($_POST['Genre']);
    }
    
    if (empty($_POST['Weight'])) {
    	$errors[] = 'Please enter Weight.';
    } else {
    	$we = trim($_POST['Weight']);
    }
    
    if (empty($_POST['Supplier'])) {
    	$errors[] = 'Please enter Supplier.';
    } else {
    	$sup = trim($_POST['Supplier']);
    }
    
    if (empty($_POST['Supplier_Price'])) {
    	$errors[] = 'Please enter Supplier Price.';
    } else {
    	$sp = trim($_POST['Supplier_Price']);
    }
    
    if (empty($_POST['Cashback'])) {
    	$errors[] = 'Please enter Cashback %.';
    } else {
    	$cb = trim($_POST['Cashback']);
    }
    
    if (empty($_POST['Cashback_Amount'])) {
    	$errors[] = 'Please enter Cashback Amount.';
    } else {
    	$cba = trim($_POST['Cashback_Amount']);
    }
    
    if (empty($errors)) {
    
    	require_once ('connect.php');
    
    	[b]$q = "INSERT INTO `Products` (`SKU_ProductID`, `SKU_MerchSKUID`, `Game_Title`, `Platform`, `Genre`, `Weight`, `Supplier`, `Supplier_Price`, `Cashback`, `Cashback_Amount`) VALUES ('$sid', '$mid', '$gt', '$pl', '$ge', '$we', '$sup', '$sp', '$cb', '$cba')";
    	$r = @mysql_query ($dbc, $q);
    
    	if ($r) { // If it ran OK.
    
    		// Print a message:
    		echo '<h1>Thank you!</h1>
    	<p>Product Inserted!</p><p><br /></p>';	
    
    	} else { // If it did not run OK.
    
    		// Public message:
    		echo '<h1>System Error</h1>
    		<p class="error">You could not be registered due to a system error. We apologize for any inconvenience.</p>'; 
    
    		// Debugging message:
    		echo '<p>' . mysqli_error($dbc) . '<br /><br />Query: ' . $q . '</p>';
    
    	} // End of if ($r) IF.
    
    	mysqli_close($dbc); // Close the database connection.[/b]		
    	// Include the footer and quit the script:
    	include ('includes/footer.html'); 
    	exit();
    
    } else {
    
    	echo '<H1>Error!</H1>
    	<p class="error">The Following error(s) occurred:<br />';
    
    	foreach ($errors as $msg) {	
    
    		echo " - $msg<br />\n";
    	}
    
    	echo '</p><p>Please try again.</p><p><br /></p>';
    
    }
    
    }
    
    ?>

     

    If there is anything else needed let me know

  4. Hi I am having problems with this script checked and checked but with no joy can you assist a php newb

     

    <?php # Product Entry
    
    $page_title = 'Product Entry';
    
    if (isset($_POST['Submit'])) {
    
    $errors = array();
    
    if (empty($_POST['SKU_ProductID'])) {
    	$errors[] = 'Please enter Product ID.';
    } else {
    	$sid = trim($_POST['SKU_ProductID']);
    }
    
    if (empty($_POST['SKU_MerchSKUID'])) {
    	$errors[] = 'Please enter Merchant SKU.';
    } else {
    	$mid = trim($_POST['SKU_MerchSKUID']);
    }
    
    if (empty($_POST['Game_Title'])) {
    	$errors[] = 'Please enter Game Title.';
    } else {
    	$gt = trim($_POST['Game_Title']);
    }
    
    if (empty($_POST['Platform'])) {
    	$errors[] = 'Please enter Platform.';
    } else {
    	$pl = trim($_POST['Platform']);
    }
    
    if (empty($_POST['Genre'])) {
    	$errors[] = 'Please enter Genre.';
    } else {
    	$ge = trim($_POST['Genre']);
    }
    
    if (empty($_POST['Weight'])) {
    	$errors[] = 'Please enter Weight.';
    } else {
    	$we = trim($_POST['Weight']);
    }
    
    if (empty($_POST['Supplier'])) {
    	$errors[] = 'Please enter Supplier.';
    } else {
    	$sup = trim($_POST['Supplier']);
    }
    
    if (empty($_POST['Supplier_Price'])) {
    	$errors[] = 'Please enter Supplier Price.';
    } else {
    	$sp = trim($_POST['Supplier_Price']);
    }
    
    if (empty($_POST['Cashback'])) {
    	$errors[] = 'Please enter Cashback %.';
    } else {
    	$cb = trim($_POST['Cashback']);
    }
    
    if (empty($_POST['Cashback_Amount'])) {
    	$errors[] = 'Please enter Cashback Amount.';
    } else {
    	$cba = trim($_POST['Cashback_Amount']);
    }
    
    if (empty($errors)) {
    
    	require_once ('connect.php');
    
    	$q = "INSERT INTO Products (SKU_ProductID, SKU_MerchSKUID, Game_Title, Platform, Genre, Weight, Supplier, Supplier_Price, Cashback, 					        Cashback_Amount) VALUES ('$sid' , '$mid' , '$gt' , '$pl' , '$ge' , '$we' , '$sup' , '$sp' , '$cb' , '$cba')";
    
    	$r = @mysql_query ($dbc, $q);
    
    	if ($r) {
    
    		echo '<H1>This game has been added to the database.</H1>';
    	} else
    	{
    		echo '<H1>Product Addition Error</H1>
    		<p class="error">The game could not be added to the database.</p>';
    
    	echo '<p>' . mysqli_error($dbc) . '<br /><br />Query: ' . $q . '</p>';
    
    	}
    
    	mysqli_close($dbc);
    
    	exit ();
    
    } else {
    
    	echo '<H1>Error!</H1>
    	<p class="error">The Following error(s) occurred:<br />';
    
    	foreach ($errors as $msg {	
    
    		[b]echo " - $msg<br />\n";[/b]		}
    
    	echo '</p><p>Please try again.</p><p><br /></p>';
    
    }
    
    [b]}[/b]
    ?>
    

     

    The errors regards syntax I see on dreamweaver are in bold.

     

    Thanks

     

    Paul

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