Solved

php mysql to write a pro gram to make invoice

Posted on 2014-03-01
2
1,014 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
2 Comments
 
LVL 108

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now