Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

php mysql to write a pro gram to make invoice

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

604 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