?
Solved

php mysql to write a pro gram to make invoice

Posted on 2014-03-01
2
Medium Priority
?
1,137 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 111

Accepted Solution

by:
Ray Paseur earned 1000 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 1000 total points
ID: 39897292
If creditebalance.name is a varchar then try this:

creditebalance.name = '$nameofbill'
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

This article discusses how to implement server side field validation and display customized error messages to the client.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
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…
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…
Suggested Courses

777 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