Solved

php mysql to write a pro gram to make invoice

Posted on 2014-03-01
2
1,096 Views
Last Modified: 2014-04-25
I try to write a program for head of invoice and detail of each invoice

what wrong with the last line of the code please suggest

creditebalance.name = $nameofbill



<?php
header ('Content-type: text/html; charset=utf-8');

?>
<?php require_once('../Connections/connect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_connect, $connect);
$query_Recordset1 = "SELECT *
FROM
creditebalance
GROUP BY
creditebalance.`name`
";
$Recordset1 = mysql_query($query_Recordset1, $connect) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$mr = mysql_query("SET NAMES UTF8");
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
<?php do { ?>
  <table width="228" border="1">
    <tr>
      <td width="163">Asian  online bill conclusion</td>
      <td width="7">&nbsp;</td>
      <td width="36">&nbsp;</td>
    </tr>
    <tr>
      <td><?php echo $row_Recordset1['name'];
	   $nameofbill = $row_Recordset1['name'];
$query_Recordset2 = "SELECT *
FROM
creditebalance
WHERE
creditebalance.name = $nameofbill


";	  

Open in new window

0
Comment
Question by:teera
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 250 total points
ID: 39897193
I think we already talked about the MySQL extension, right?  I cannot imagine why you would still be posting code examples that use MySQL.

I'm going to recommend that you step back from this script and take some time to get a foundation in how PHP works.  From the look of this script, it appears that you're trying to learn PHP by copying Dreamweaver code.  And Dreamweaver has some of the worst PHP code ever written.  So just don't do that.  Instead, invest a couple of months of your life in learning the basics.   This article will get you started.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11769-And-by-the-way-I-am-new-to-PHP.html

In the instant case, the script has a parse error.  It also creates a query, but does not run the query.  It has SELECT * which is a code smell signaling "I don't know what I'm doing with SQL."  When there are anti-practices showing in the code, you can learn to avoid those by reading this article.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_12293-AntiPHPatterns-and-AntiPHPractices.html

And (sigh) the script uses the MySQL extension.  That needs to change because PHP is doing away with MySQL support.  MySQL is already deprecated.  This article explains why and what you must do to keep your scripts running in the future.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/PHP_Databases/A_11177-PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html

Best regards, and best of luck with your project, ~Ray
0
 
LVL 12

Assisted Solution

by:North2Alaska
North2Alaska earned 250 total points
ID: 39897292
If creditebalance.name is a varchar then try this:

creditebalance.name = '$nameofbill'
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question