
mourningreign
Members-
Posts
13 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
mourningreign's Achievements

Newbie (1/5)
0
Reputation
-
Counting specified fields that are not NULL
mourningreign replied to mourningreign's topic in PHP Coding Help
This- [CODE] <?php $last_Recordset1 = "1"; if (isset(1)) { $last_Recordset1 = (get_magic_quotes_gpc()) ? 1 : addslashes(1); } $last2_Recordset1 = "1"; if (isset(2)) { $last2_Recordset1 = (get_magic_quotes_gpc()) ? 2 : addslashes(2); } $last3_Recordset1 = "1"; if (isset(3)) { $last3_Recordset1 = (get_magic_quotes_gpc()) ? 3 : addslashes(3); } $last4_Recordset1 = "1"; if (isset(4)) { $last4_Recordset1 = (get_magic_quotes_gpc()) ? 4 : addslashes(4); } mysql_select_db($database_bbb, $bbb); $query_Recordset1 = "SELECT CONCAT('$',SUM('$last_Recordset1','$last2_Recordset1','$last3_Recordset1','$last4_Recordset1')) AS `count1` "; $last_Recordset1,$last2_Recordset1,$last3_Recordset1,$last4_Recordset1); $Recordset1 = mysql_query($query_Recordset1, $bbb) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> [/code] Gets this - Parse error: parse error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in /homepages/19/d125543458/htdocs/bbb/test.php on line 4 -
Counting specified fields that are not NULL
mourningreign replied to mourningreign's topic in PHP Coding Help
Did I screw it all up? <?php $last_Recordset1 = "1"; if (isset(1)) { $last_Recordset1 = (get_magic_quotes_gpc()) ? 1 : addslashes(1); } $last2_Recordset1 = "1"; if (isset(2)) { $last2_Recordset1 = (get_magic_quotes_gpc()) ? 2 : addslashes(2); } $last3_Recordset1 = "1"; if (isset(3)) { $last3_Recordset1 = (get_magic_quotes_gpc()) ? 3 : addslashes(3); } $last4_Recordset1 = "1"; if (isset(4)) { $last4_Recordset1 = (get_magic_quotes_gpc()) ? 4 : addslashes(4); } mysql_select_db($database_bbb, $bbb); $query_Recordset1 = sprintf("SELECT CONCAT('$', SUM(`%s`, `%s`, `%s`, `%s`)) AS `count1`", $last_Recordset1,$last2_Recordset1,$last3_Recordset1,$last4_Recordset1); $Recordset1 = mysql_query($query_Recordset1, $bbb) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> -
Counting specified fields that are not NULL
mourningreign replied to mourningreign's topic in PHP Coding Help
SELECT CONCAT('$', SUM(`last`, `last2`, `last3`, `last`)) AS `count1` Syntax error still -
Counting specified fields that are not NULL
mourningreign replied to mourningreign's topic in PHP Coding Help
I'll be happy to just deal with one at a time...I get a syntax error. -
I'd like to count 4 specified text fields (last,last2,last3,last4) for which contain data and sum the total then count 4 more text fields (last5,last6,last7,last8) for which contain data and sum that total. Each total which will be a number from 2-4 will have a dollar value in a related table that I can then sum and display on a page.
-
I really should be more specific when posting. Purpose: On a request for a hotel room reservation the user selects how many people in a room. The user has to fill in the full names of each additional person in the room. Rooms are only booked as doubles, triples or quads. So if name fields name1 & name2 are set to not null we need only to start at 2 and +1 for name3 and +1 for name4. Could you also explain what each line does so that I can have a clue? We could then compare the menu value to this calculation. I'm thinking this is a pass through script situation using session variables to hold the data or maybe a calculation table in the database would be better.
-
I have done this with a calculation of percentage and store the data in a database. Then I send them to Paypal to make the payment. I then validated that they made payment buy letting Paypal send them to a page on completion of purchase and checking to see the referring URL. Unfortunately, these were preset payment values.
-
Within a form I'd like to compare 2 values. The first, a value selected froma menu (1-4). The second, taken from counting how many of 4 specific fields contain data. If the values match pass the data to the database, if not die and give an error. This is probably simple for a pro but I don't have a clue.
-
if else statement returns same value?
mourningreign replied to mourningreign's topic in PHP Coding Help
:D This works: <?php $a = 'Not a Member'; $b = 'a Member'; $c = '<a href="vip/comp.php">Click here for a complimentary VIP level membership.</a>'; $d = ' '; if (strcmp($row_rsDJeventsignup['member'],$a)==0) { echo $c; } ?> -
The goal of this is to [b]not return[/b] the link if the user is a member. This page follows a query of the database after a form submission for an event signup. I've tried it with single = and the result is the same. Inquiries to my local php user group just have me more confused. The rs is returning the correct value and no errors are coming up. <?php $a = 'Not a Member'; $b = 'a Member'; $c = '<a href="vip/comp.php">Click here for a complimentary VIP level membership.</a>'; $d = ' '; if ($row_rsDJeventsignup['member'] == $a) echo $c; elseif ($row_rsDJeventsignup['member'] == $b); echo $d; ?>
-
The first page: Starts the session and gets the session value from the form. [code]session_start(); $_SESSION['picture'] = $_POST['picture'];[/code] The second page: Starts the session and attempts to place the session value in a new form. [code]session_start(); $_SESSION['picture'];[/code] [code]<input name="upload0" type="file" value="<?php echo $_SESSION['picture']; ?>" size="25" />[/code] Nothing displays!
-
Maybe I've been looking at it too long. I just want it to add [code] picture=$_POST['picture'] [/code] after the ? it is already adding to the URL. [code] $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO cmsarticles (title, tagline, author, picture, `section`, thearticle, approved) VALUES (%s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['title'], "text"), GetSQLValueString($_POST['tagline'], "text"), GetSQLValueString($_POST['author'], "text"), GetSQLValueString($_POST['picture'], "text"), GetSQLValueString($_POST['section'], "int"), GetSQLValueString($_POST['thearticle'], "text"), GetSQLValueString($_POST['approved'], "text")); mysql_select_db($database_core, $core); $Result1 = mysql_query($insertSQL, $core) or die(mysql_error()); $insertGoTo = "pictureupload.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } [/code] It's times like these when I realize what a PHP beginner I am! So much for patting myself on the back... Rage