My PHP problem (urgent)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
anticraft
Forum Newbie
Posts: 1
Joined: Wed Dec 06, 2006 9:56 am

My PHP problem (urgent)

Post by anticraft »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I have been stuck by this for nearly 1 whole day. I am new in PHP, so I may have a bundle of silly questions.

My boss begin to ask about how I have achieved here. So I am really in urgent.

I have created a php and upload it into a ftp.

Then I run it by copy the url of the file.

But the result is only a part of the code. So I am lost.

The code is like this:

Code: Select all

<?php
	set_time_limit(600); 
	
	//Connecting and selecting database 
	$link = mysql_connect( 'xxx', 'yyy', 'zzz)
	or die( 'Could not connect:'.mysql_error());
	mysql_selectdb( 'aaa', $link) or die('Could not connect to database'. mysql_error());
	
	//just for test
	$artikelNr = "0101001001001";
	$kundengruppe = "6";
	$menge = "1.00";
	
	//Variables
	$Neu_brutto="";
	$Rabatt_1="";
	$Rabatt_2="";
	$Aufschlag="";
	
	/*$artikelNr = $_POST['artikelNr'];
	$kundengruppe = $_POST['kundengruppe'];
	$menge = $_POST['menge'];*/
	
	$Typ = substr($artikelNr, 0, 4);
	$Farbe = substr($artikelNr, 4, 3);
	$Material = substr($artikelNr, 7, 3);
	$MassNr = substr($artikelNr, 10, 3);
	echo $Farbe;
	
	//Query to extract Sonderpreis from database
	$queryKN = "SELECT `SP_PREIS`,`SP_RABATT_1` FROM `sonderpreise` 
		WHERE (`SP_ARTIKEL`= '$artikelNr') 
		AND (`SP_KONTO` = '$kundengruppe') 
		AND (`SP_MENGE` = '$menge')"; 
			
	//Confirm that the query has been completed
	$result = mysql_query($queryKN) or die ('Query failed:' .mysql_error());
	
	
	// Count the number of rows returned. If 1 then  output
	$num_rows = mysql_num_rows($result);
			
	if ( $num_rows == 1) {
		$resultsArray = mysql_fetch_array($result, MYSQL_NUM);
		
		// Results from first query with Kunden Nr associated to the Preis and Rabatt variables
		$Preis = $resultsArray[0];
		$Rabatt_1 = $resultsArray[1];
				
		echo "1~".$Preis ."~". $Rabatt_1;
	}

	// if more than 1 row return or no row return, go to step 2
	else if ( $num_rows <> 1){
		//step 2 Kombination
		$queryKN = "SELECT KO_AUFSCHLAG
				FROM `KOMBINATION`
				WHERE `KO_TYP` = $Typ
				AND `KO_FARBE` = $Farbe
				AND `KO_MATERIAL` = $Material";
			
		//Confirm that the query has been completed
		$result = mysql_query($queryKN) or die ('Query failed:' .mysql_error());
		
		
		// Count the number of rows returned. If 1 the  output
		$num_rows = mysql_num_rows($result);
		
		if ( $num_rows == 1) {
			
			$resultsArray = mysql_fetch_array($result, MYSQL_NUM);
			
			$Aufschlag = $resultsArray[0];
			
			echo "2~". $Aufschlag;
		}
		// if more than 1 row return or no row return, go to step 3
		else if ( $num_rows <> 1) {
			//step 3 Preise
			$queryKN = "SELECT PR_PREISE
				FROM `PREISE`
				WHERE `PR_TYP` = $Typ
				AND `PR_FARBE` = $Farbe
				AND `PR_MATERIAL` = $Material
				AND `PR_MASS` = $MassNr";
				
			//Confirm that the query has been completed
			$result = mysql_query($queryKN) or die ('Query failed:' .mysql_error());
			
			// Count the number of rows returned. If 1 the  output
			$num_rows = mysql_num_rows($result);
			
			if ( $num_rows == 1) {
				
				$resultsArray = mysql_fetch_array($result, MYSQL_NUM);
				
				$Neu_brutto = $resultsArray[0];
				
				echo "3~". $Neu_brutto;
			}
			// if more than 1 row return or no row return, go to step 4
			else if ( $num_rows <> 1) {
				//step 4 Rabatt
				$queryKN = "SELECT rabatt.RABATT1, rabatt.RABATT2
				
					FROM rabatt INNER JOIN ARTIKELSTAMM ON rabatt.ARTIKEL_RABATTGRUPPE = ARTIKELSTAMM.AR_RAB_GRP
					
					WHERE ( rabatt.KUNDEN_RABATTGRUPPE = $kundengruppe ) AND ( ARTIKELSTAMM.AR_NUMMER = $artikelNr )";
					
				//Confirm that the query has been completed
				$result = mysql_query($queryKN) or die ('Query failed:' .mysql_error());
				
				// Count the number of rows returned. If 1 the  output
				$num_rows = mysql_num_rows($result);
				
				if ( $num_rows == 1) {
					
					$resultsArray = mysql_fetch_array($result, MYSQL_NUM);
					
					$Rabatt_1 = $resultsArray[0];
					
					$Rabatt_2 = $resultsArray[1];
				
					echo "4~". $Rabatt_1 ."~". $Rabatt_2;
				}
				// if more than 1 row return or no row return, go to step 5
				else if ( $num_rows <> 1) {
					//Step 5 aufschlag
					$queryKN = "SELECT * FROM `AUFSCHLAG`
						
						WHERE `AS_TYP` = $Typ
						
						AND `AS_MATERIAL` = $Material";
						
					//Confirm that the query has been completed
					$result = mysql_query($queryKN) or die ('Query failed:' .mysql_error());
					
					// Count the number of rows returned. If 1 the  output
					$num_rows = mysql_num_rows($result);
					
					if ( $num_rows == 1) {
						
						$resultsArray = mysql_fetch_array($result, MYSQL_NUM);
						
						$Aufschlag = $resultsArray[0];
					
						echo "5~". $Aufschlag;
					}
					// if more than 1 row return or no row return, return error message
					else if ( $num_rows <> 1) {
						echo "null~null~null";
					}
				}
			}
		}
	}
	
// Closing connection
mysql_close($link);
?>
The result is just half part the code from else if ( $num_rows <> 1) .

So does anyone have anyidea what happened?Thanks very much


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
evilchris2003
Forum Contributor
Posts: 106
Joined: Sun Nov 12, 2006 6:43 am
Location: Derby, UK

Post by evilchris2003 »

Take time to read the forum rules before posting your code

use the

Code: Select all

tags around your code

it would also be helpful if you post any errors you are getting
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

1 Secs
anticraft wrote:

Code: Select all

<?php 
        set_time_limit(600); 
        
        //Connecting and selecting database 
        $link = mysql_connect( 'xxx', 'yyy', 'zzz)
Put A ; In The Last Line Please It Would Make It Easy To Understand[/quote]
Post Reply