Solved

php mysql to write a pro gram to make invoice

Posted on 2014-03-01
2
1,073 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 109

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP query / monitor data from Telnet to MySQL 7 48
SQL trigger 5 21
Wordpress Only run code if on a certain page 11 22
issue with DB import 1 17
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses four methods for overlaying images in a container on a web page
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.

839 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