PHP/MySQL Record Insert question
I am working with which PHP 4.4.2, MySQL Server 5.0 running
on Apache 2.0.55, and I am developing my web-site with Dreamweaver
8. All of which is running locally on my machine.
I am working on a real-estate website that allows landlords
around my local area to login to the web-site and add their
apartment or housing rental units into a database that students
that go to my small university can browse and search through. The
landlords register through a form that loads into a 'landlords'
table in the database and MySQL auto-increments an ID into a
'landlord_id' column which obviously assigns them their
'landlord_ID'.
My question is: When the landlord is filling out the form to
add one of their rental units ( which loads into a separate table I
called 'sites'), how can I make their 'landlord_id' (which resides
in the 'landlords' table) be entered into the 'landlord_id' column
in the 'sites' table for each site that they enter into the
database?
I'm trying to do this because when the landlord first logs
in, I'm going to have a dynamic table that displays all of the
sites they already have entered in the database, and only displays
their sites that they have already entered in by only displaying
the sites that have their 'landlord_id' in the site record.
Thanks so much for your help, and if I'm being confusing at
all, please reply or email me so I can clarify.
Cade06 wrote:
> Thanks alot for your reply, but I am completely new to
MySQL, and I am not
> quite sure how the syntax works. When you say " WHERE
landlord_username =
> 'whatever' "I'm not sure what needs to go in the
'whatever' portion of the
> code. Do I need to insert static text here or something
else? I am totally out
> of my element here, sorry :-/
It's probably not so much MySQL syntax that's the problem for
you, but a
lack of understanding how to work with Dreamweaver
recordsets, server
behaviors, and sessions. Building database-driven sites with
Dreamweaver
isn't difficult, but there are a lot of things involved.
The Log In User server behavior automatically creates a
session variable
called $_SESSION['MM_Username']. You can use this as a
parameter to pass
to the SQL query in the Advanced Recordset dialog box. In the
SQL area
you would type (I'm guessing the name of your table and the
username
column):
SELECT landlord_id FROM landlords
WHERE landlord_username = 'col1'
Then click the plus button above the Variables area, and
create a
Parameter with the following values:
Name: col1
Default value: 1
Runtime value: $_SESSION['MM_Username']
You can then extract the result of the recordset, and assign
it to a
session variable like this:
$_SESSION['landlord_id'] = $row_recordsetName['landlord_id'];
> Also, I understand that I need to do this on the login
page, but do I need to
> define the recordset again on the add_site page as well?
I guess I'm still not
> quite clear on how I specify the session variable as the
value that needs to be
> entered in the sites table as the landlord_ID.
As long as the session is still valid (which it would be if
you use
Restrict Access to Page), you will always have access to that
landlord's
id through $_SESSION['landlord_id'].
David Powers
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "Foundation PHP 5 for Flash" (friends of ED)
http://foundationphp.com/
Similar Messages
-
PHP MYSQL and DW Question: Invalid characters and new lines entry/viewing
Hello all,
I have followed David Powers' two php/dw/mysql books and I've
set up PHP
pages that insert, edit, delete, etc. listings. Everything
works fine
except for invalid characters being inserted into the
database, and then
displaying with a question mark in firefox.
Is there a trick to cleaning up the data that a user may
paste into a
textbox on a web page for insertion in the database before
the data is
inserted or as it is inserted? Em dashes, en dashes, 'curly
quotes' etc.
are giving me problems.
Also, when I enter new lines into the php page while I'm
typing out
information for a record, these new lines are not being
displayed either
in the database (using phpmyadmin to view) or on the
resulting details
pages, even though I'm using nl2br, etc. Is there a way to
make this
work reliably?
Thank you for any help you may give me!
-JohnHello all,
I have followed David Powers' two php/dw/mysql books and I've
set up PHP
pages that insert, edit, delete, etc. listings. Everything
works fine
except for invalid characters being inserted into the
database, and then
displaying with a question mark in firefox.
Is there a trick to cleaning up the data that a user may
paste into a
textbox on a web page for insertion in the database before
the data is
inserted or as it is inserted? Em dashes, en dashes, 'curly
quotes' etc.
are giving me problems.
Also, when I enter new lines into the php page while I'm
typing out
information for a record, these new lines are not being
displayed either
in the database (using phpmyadmin to view) or on the
resulting details
pages, even though I'm using nl2br, etc. Is there a way to
make this
work reliably?
Thank you for any help you may give me!
-John -
Php/MySQL database insert record issue...
I have a php page that adds an "order" to a mysql database table (orders). One text field in the form is for tires/wheels. The description of the wheels often includes the " symbol for inches after a number....Everything submits fine, however when I look at the page that displays the orders all the data after the " symbol including the " symbol is gone... DOes anyone have any idea why this may be happening? It is requiring us to return and edit that area repeatedly. Any help is appreciated greatly. Thanks for your time.
Ok, so just to summarize so I am understanding this correctly. You have an ordering page for tires/wheels. A customer places an order for tires/wheels and the data is submitted successfully and this includes a symbol for measurement (in.). But on another summary page the symbol is returning a blank value.
If this is correct we need to see:
- First, the code that is inserting the symbol to the database table in question
- Second, the query and code where you are printing the data to the screen. -
PHP/MySQL-Update/Insert Record JavaScript Won't Work!!!
Hi. I'm consistently running into the following error when I use the update or insert record script in CS4. I've tried deleting the FileCache file. I've tried quitting and relaunching, etc. Anyone else seeing this happen? Solutions anyone? Thanks in advance...
I'm beginning to think it has something to do with the database, and not the script. Does anything in the screenshot below look wrong or problematic?
Okay, I found the problem. Shouldn't be a problem, but it is...
The Field name "length" changed to "height" eliminated the problem. So, you can't use the word "length" in a field? Sounds weird to me.airsoftie wrote:
Okay, I found the problem. Shouldn't be a problem, but it is...
The Field name "length" changed to "height" eliminated the problem. So, you can't use the word "length" in a field? Sounds weird to me.
There are lots of words you can't use for column names in MySQL, but "length" isn't one of them. See http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html.
The problem arises because Dreamweaver uses JavaScript behind the scenes to populate dialog boxes and build server behaviors. In JavaScript, "length" is the property of an array. I suspect the problem is that using "length" as a column name has given the relevant JavaScript used by Dreamweaver indigestion. -
[php+mysql] how to get the inserted record ID?
Hi all,
I have a standard php page that inserts a record in a mysql
db.
is there a way to save the record ID on a session variable
just after
storing the new record on the db? I would like to be able to
get this
record ID on a specific page where I would allow the user to
print
this specific record, by filtering the db by this session
variable.
I can use MX Kollection (last version, not PRO).
TIA
tony>...
>mysql_query(...);
>$_SESSION['lastId'] = mysql_insert_id();
>HTH
>Micha
Hi Micha,
I think that it a bit more complicated.
I can't find any occurrence of that mysql call.
I used MX Kollection INSERT FORM function.
here is the code (partially):
===============================
<? // Load the common classes
require_once('../includes/common/KT_common.php');
// Load the tNG classes
require_once('../includes/tng/tNG.inc.php');
// Make a transaction dispatcher instance
$tNGs = new tNG_dispatcher("../");
// Make unified connection variable
$conn_test_conn = new KT_connection($tes_conn,
$database_test_conn);
// Start trigger
$formValidation = new tNG_FormValidation();
$tNGs->prepareValidation($formValidation);
// End trigger
// Make an insert transaction instance
$ins_rl_test = new tNG_insert($conn_test_conn);
$tNGs->addTransaction($ins_rl_test);
// Register triggers
$ins_rl_test->registerTrigger("STARTER",
"Trigger_Default_Starter", 1,
"POST", "KT_Insert1");
$ins_rl_test->registerTrigger("BEFORE",
"Trigger_Default_FormValidation", 10, $formValidation);
$ins_rl_test->registerTrigger("END",
"Trigger_Default_Redirect", 99,
"2.php?idp1={id_rl}");
// Add columns
$ins_rl_test->setTable("rl_test");
$ins_rl_test->addColumn("nome_rl", "STRING_TYPE", "POST",
"nome_rl");
$ins_rl_test->addColumn("cognome_rl", "STRING_TYPE",
"POST",
"cognome_rl");
$ins_rl_test->addColumn("datanascita_rl", "DATE_TYPE",
"POST",
"datanascita_rl");
$ins_rl_test->addColumn("cancellato_rl", "STRING_TYPE",
"POST",
"cancellato_rl");
$ins_rl_test->addColumn("cancellato_data_rl", "DATE_TYPE",
"POST",
"cancellato_data_rl");
$ins_rl_test->setPrimaryKey("id_rl", "NUMERIC_TYPE");
// Execute all the registered transactions
$tNGs->executeTransactions();
// Get the transaction recordset
$rsrl_test = $tNGs->getRecordset("rl_test");
$row_rsrl_test = mysql_fetch_assoc($rsrl_test);
$totalRows_rsrl_test = mysql_num_rows($rsrl_test);
?>
===========================
as you can see, all data is processed by other functions in
other
included files.... :(.
I think I need to better understand the TNG engine and try to
create a
little trigger that creates a session variable just after
inserting
the record in the db.
I already tried to do so, honestly, but with really poor
results.
Ciao Micha. ;).
tony -
Record insertion problem and another question...
I know I'm now php mysql expert so I am trying to use the
insertion wizard and I can make the form and have it supposed to
link to another page after its done inserting but when I run the
page and fill in the details it inserts the record but does not
goto the directed page and also shows the error:
Warning: Cannot modify header information - headers already
sent in C:\wamp\www\toursite\admin\users\add.php on line 56
and on line 56 is:
header(sprintf("Location: %s", $insertGoTo));
Can anyone help me here?
My second problem is not really a dreamweaver problem but it
may be linked to it. Im using a server package called WAMP and
pages that I can run will sometimes cause and error box to popup
saying that Apache has caused error, the box that gives you the
option of sending the report or not. Anyone know what the problem
is here?
If I have not given enough information to help please ask for
more.
Thanks
Danmondan wrote:
> Warning: Cannot modify header information - headers
already sent in
> C:\wamp\www\toursite\admin\users\add.php on line 56
> and on line 56 is:
> header(sprintf("Location: %s", $insertGoTo));
> Can anyone help me here?
The headers already sent error is a common problem that
baffles
beginners. It's caused by some output being sent to the
browser before a
call to certain functions, such as header() or
session_start(). You need
to eliminate that output, and the problem will go away.
Common causes of output are:
* Blank space before the opening PHP tag
* Blank space before the opening PHP tage or after the
closing PHP tag
of any include files
* Use of echo or print anywhere before the call to the
problem function
* Error messages generated by PHP
> Im using a server package called WAMP and pages that I
can run will
> sometimes cause and error box to popup saying that
Apache has caused error, the
> box that gives you the option of sending the report or
not.
None of the server packages are endorsed by PHP. Some are
good, others
not so good. It sounds as though you have a bad installation.
Seek
advice from the WAMP team or support forum if they have one.
David Powers
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "Foundation PHP 5 for Flash" (friends of ED)
http://foundationphp.com/ -
CS6 Dreamweaver using PHP & MySQL - Delete Record Server Behavior?
When I try to insert the Delete Record server behavior. I get an error message about a DeleteRecord.js file, which seems to be missing or defective. I cannot use the server behavior. I have a file that I developed using CS5, and it does indeed delete the record, but does not proceed to the destination I want. I cannot change that except in the server behavior, so I'm stuck. I have noticed that server behaviors seem to disappear without apparent cause, as it seems to have in this case. I will appreciate any suggestions! Is there any way to embed a call to a target page manually? All is working WITHOUT the server behavior appearing, but I want to go to a confirmation display page that shows the record is indeed deleted, and we just return to the (now blank) delete confirmation page. That'll drive a user bonkers!
Thanks!
Delete Record in CS6 Dreamweaver using PHP & MySQL?Well, your error message is self-explanatory.
DW stores ServerBehaviors in 'Configuration' folder in installation directory. If one of the behavior JS files is missing/ corrupt, you'll see the error message you just did.
I've uploaded a functional, proper version of DeleteRecord.js onto my site for you to download. Here's the link:
http://www.sudarshan.me/adobeforum/dw/app/behavior-js/DeleteRecord.zip
Download this file, extract it and put DeleteRecord.js file in your installation directory as follows. If prompted, 'replace' your local copy:
Mac: Applications > Adobe Dreamweaver CS6 > Configuration > ServerBehaviors > PHP_MySQL
Windows: C:\Users\Your User Name\AppData\Roaming\Adobe\Dreamweaver CS6\[language]\Configuration\ServerBehaviors\PHP_MySQL
It should work as expected.
If that still doesn't solve the problem, reset your DW preferences and cache and try doing it. Follow the instructions here to reset cache: http://forums.adobe.com/thread/494811
Let us know how it goes.
-ST -
I am new to php/MYSQL but I am trying to learn. I built an
insert page using DW8. I was looking back over the code trying to
figure it out. Is it just me or does dreamweaver an a bunch of junk
to there code to do a simple insert from 4 form fields.
Can anyone explain what DW is doing since I am now dumber for
having looked at it.
<?php
function GetSQLValueString($theValue, $theType,
$theDefinedValue = "", $theNotDefinedValue = "")
$theValue = (!get_magic_quotes_gpc()) ?
addslashes($theValue) : $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;
$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 reviews (review_date,
review_name, review_address1, review_city, review_state) VALUES
(%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['date'], "date"),
GetSQLValueString($_POST['textfield'], "text"),
GetSQLValueString($_POST['textfield2'], "text"),
GetSQLValueString($_POST['textfield3'], "text"),
GetSQLValueString($_POST['textfield4'], "text"));
mysql_select_db($database_siteData, $siteData);
$Result1 = mysql_query($insertSQL, $siteData) or
die(mysql_error());
$insertGoTo = "
http://www.yahoo.com/";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
header(sprintf("Location: %s", $insertGoTo));
mysql_select_db($database_siteData, $siteData);
$query_Recordset1 = "SELECT * FROM reviews";
$Recordset1 = mysql_query($query_Recordset1, $siteData) or
die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>newhorizonhosting.com wrote:
> I am new to php/MYSQL but I am trying to learn. I built
an insert page using
> DW8. I was looking back over the code trying to figure
it out. Is it just me or
> does dreamweaver an a bunch of junk to there code to do
a simple insert from 4
> form fields.
No, it's not a bunch of junk. It's filtering the input to
make sure that
things are inserted correctly into your database.
> Can anyone explain what DW is doing since I am now
dumber for having looked at
> it.
This function filters the form content to prepare it for
insertion in
the database.
> function GetSQLValueString($theValue, $theType,
$theDefinedValue = "",
> $theNotDefinedValue = "")
This sets the action value of the form tag, including any
query string.
> $editFormAction = $_SERVER['PHP_SELF'];
> if (isset($_SERVER['QUERY_STRING'])) {
> $editFormAction .= "?" .
htmlentities($_SERVER['QUERY_STRING']);
> }
This builds the SQL query and inserts the form content into
the database.
> if ((isset($_POST["MM_insert"])) &&
($_POST["MM_insert"] == "form1")) {
> $insertSQL = sprintf("INSERT INTO reviews (review_date,
review_name,
> review_address1, review_city, review_state) VALUES (%s,
%s, %s, %s, %s)",
> GetSQLValueString($_POST['date'], "date"),
> GetSQLValueString($_POST['textfield'], "text"),
> GetSQLValueString($_POST['textfield2'], "text"),
> GetSQLValueString($_POST['textfield3'], "text"),
> GetSQLValueString($_POST['textfield4'], "text"));
>
> mysql_select_db($database_siteData, $siteData);
> $Result1 = mysql_query($insertSQL, $siteData) or
die(mysql_error());
This redirects the page after the database query has
finished.
> $insertGoTo = "
http://www.yahoo.com/";
> if (isset($_SERVER['QUERY_STRING'])) {
> $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" :
> $insertGoTo .= $_SERVER['QUERY_STRING'];
> }
> header(sprintf("Location: %s", $insertGoTo));
> }
This is unrelated to the insert. It's a recordset that
retrieves
everything from the reviews table of your database.
> mysql_select_db($database_siteData, $siteData);
> $query_Recordset1 = "SELECT * FROM reviews";
> $Recordset1 = mysql_query($query_Recordset1, $siteData)
or die(mysql_error());
> $row_Recordset1 = mysql_fetch_assoc($Recordset1);
> $totalRows_Recordset1 = mysql_num_rows($Recordset1);
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/ -
Inserting special character like apostrophes with PHP/Mysql
Hi friends,
I have a problem with php/mysql. I have created a form inton a php page with dreamweaver and when i try to fill the form with a string containing apostrophe ( ' ), i have a error. It seems that the insertion is not possible. Could you have any idea for that. I give you the php dreamweaver code and thank you for your help.
<?php require_once('Connections/Mainconnect.php'); ?>
<?php require_once('Zend/Date.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":
if ($theValue=="")
$theValue="NULL";
else
$zendDate=new Zend_Date($theValue,"dd/MM/yyyy");
$theValue="'".$zendDate->toString("yyyy-MM-dd")."'";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
return $theValue;
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE pers_soc_reg SET field1=%s, field2=%s,
GetSQLValueString($_POST['field1'], "text"),
GetSQLValueString($_POST['field2'], "double"));"Normally, you canot use mysql_real_escape_string without connection to database"
That is not true at all. Try running the following script.
<?php
if ($_POST['submit']){
$x1=$_POST['test1'];
foreach ($_POST as $key => $value) {
if (!is_array($value)){
$_POST[$key] = mysql_real_escape_string($value);
extract($_POST);
echo "The text after 'becomes' should be escaped (\')<br/>";
echo "$x1 becomes $test1<br/>";
?>
<hr/>
<form action="#" method="post" />
Enter some text, including an apostrophe: <input name="test1" type="text"><br/>
<p><input name="submit" value="submit" type="submit"/>
</form> -
I realise that this is probably a simple question and I'm just looking for some general pointers. I've already looked through these forums and on the web so don't all jump down my throat at once!
If I want to insert multiple records into a Mysql database/table, can I do it through Dreamweaver Insert Record function and using a repeat region, or can multiple inserts only be done through programming the PHP/Mysql side of things?
I need to insert a row for each player in a football match, and need to input starting 11, subs, man of the match etc with checkboxes, so have binded the checkboxes to the table and would like to use a repeat region if this is poss? Or will I have to insert a separate row of checkboxes for each player?
Any advice much appreciated
Cheers all
BezI figured out the method to insert record with auto increment primary key. I listed the code block below:
char m_SeqNamePositions[32] = "MyPositions";
DbSequence *m_pSeqPositions;
m_pDBPositions = new Db(NULL, 0);
m_pDBPositions->open(NULL, pszFileName, szFileName, DB_BTREE, DB_CREATE, 0); // 无数据文件
m_pSeqPositions = new DbSequence(m_pDBPositions, 0);
Dbt key((void *)m_SeqNamePositions, (u_int32_t)strlen(m_SeqNamePositions));
m_pSeqPositions->open(NULL, &key, DB_CREATE);
db_seq_t SeqNum;
m_pSeqPositions->get(0, 1, &SeqNum, 0);
Dbt key((void *)&SeqNum, (u_int32_t)sizeof(SeqNum));
Dbt data(pRecord, sizeof(*pRecord));
return m_pDBPositions->put(NULL, &key, &data, DB_NOOVERWRITE);
m_pSeqPositions->close(0);
m_pDBPositions->close(0);
delete m_pSeqPositions;
delete m_pDBPositions;
m_pDBPositions = NULL; -
[php+mysql] best way to integrate a tree category menu base on db?
Hi all,
I have a products catalog where all products are organized in
categories.
The category structure is something similar to this:
category 1
subcategory 1.1
sub-subcategory 1.1.1
sub-subcategory 1.1.2
sub-subcategory 1.1.3
sub-subcategory 1.1.4
sub-subcategory 1.1.5
subcategory 1.2
subcategory 1.3
category 2
subcategory 2.1
subcategory 2.2
sub-subcategory 2.2.1
sub-subcategory 2.2.2
sub-subcategory 2.2.3
sub-subcategory 2.2.4
subcategory 2.3
...and so on...
In general, I have 3 category levels.
I manage these catagories with only one table using self
foreign keys.
Now I need to add a tree menu that will reflect the above
category
structure.
I use php + mysql to store the tables (products and
categories.
I found several javascript samples that allow you to do
something similar
but with static data.
I'm searching for a tree menu that is easily customizable and
that can use
dynamic data from mysql db.
Is there a tutorial or smple that would do the trick?
TIA very much!
tony ;).The page I'm trying to create is here www.hollisterairshow.com/plan-results.php and the questionnaire is here www.hollisterairshow.com/helpusplan.php .
I went ahead and created recordsets using advanced recordsets and these seem to be working, here's a sample SQL
SELECT *
FROM plan
WHERE Saturday = 'Saturday' AND plan.howArriving = 'Auto'
I created a recordset for each combination of day and transportation mode - six in all
This selected the correct records.
To display the count of how many records selected I then used in DW Insert/Data Objects/ Display Record Count/Total Records which generated the following code:
<?php echo $totalRows_rsSatAuto ?>
This worked OK - not elegant but OK and I repeated it for each combination of Day and Transportation mode!!
So there are two problems I'm having:
I know I can select the records I want but how do I display the sum of the column containing "How many in your party" - i.e. in the PHP code generated above what do I replace $totalRows_rsSatAuto with?
There are two questions using radio buttons where I'd like to display the count and % for each option selected. I can select all records for these questions but what code do I put to sum the number of selections for each option and what code do I put to calculate the percentage
I understand the arithmetic involved which is pretty simple but it's the mechanics of coding that has me stumped. It would really help if you could give me a sample for say the "Are you camping overnight" question which has a "Yes/No" option only. In my mundane way I would create two recordsets, one for "Yes" and one for "No", and use the same technique I describe above for counting Total Records in each recordset, but then I'm stuck with how do I calculate and display the percentages. I must be missing something very obvious as I'm sure there just has to be a more elegant solution.
Thanks so much for your continued interest.
Tony -
PhP/MySQL Horizontal/Vertical Repeat Region
Hi Guys,
I'm pretty sure this question would have been asked many times before. If so, first of all my apologies for re-posting this.
Anyway, what I'm trying to do is create a repeat region that spans for 4 columns and then repeats the rest in rows. For example, if I have 100 records in my table (MySQL), then I want to display this in a table of 4 columns and and 25 rows (in reality, the number of records would be unspecified, of course, but still the records need to be displayed on a 4 column, X row table). For example:
name
comment
name
comment
name
comment
name
comment
name
comment
name
comment
name
comment
name
comment
name
comment
name
comment
name
comment
name
comment
name
comment
name
comment
name
comment
name
comment
name
comment
name
comment
name
comment
name
comment
At the moment, I have no issue with displaying the records either horizontally or vertically (explicitly) using the built in "repeat region" behavior. However, where I'm having the problem is with displaying the records in a table as the one I described above.
I'm using DW CS5 with PhP/MySQL.
Can I still do this using the built in "repeat region" server behavior, if so how?
Otherwise, how else could I achieve this (ideally without using any extensions)?
Thanks in advance for any help and support,
CheersI'm believe you should be able to modify the repeat region code to do what you want it to do. With that said we will need 2 things:
1. To see the code from the page.
2. To know the order of the results is it:
Horizontal: 1 2 3 4
5 6 7 8
Or Vertical:
1 5
2 6
3 7
4 8 -
I've posted this before and didn't get the answer that I need, probably because I didn't post all of my codes. I am using PHP/MySql. I created a website that has several forms. When I process three of the forms, I get the error messages below:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Condition, Length, Color, City, `State`, Email, Photo) VALUES ('29', '4', 'Used'' at line 1.
Below I am posting the codes. Hopefully, this time I posted everything that I should have so that I can get assistance.
FORM
<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="individual" class="individual" id="individual">
<table width="594" border="0" class="test">
<tr></tr>
<tr>
<td width="166" class="td">Posting Title</td>
<td colspan="3"><span id="sprytextfield1">
<label>
<input name="Posting Title" type="text" class="test" id="Posting Title" size="35" />
</label>
<span class="textfieldRequiredMsg">Required</span></span></td>
</tr>
<tr>
<td class="td">Price</td>
<td colspan="3"><span id="sprytextfield2">
<label>
<input name="price" type="text" class="test" id="price" size="35" />
</label>
<span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
</tr>
<tr>
<td class="td">Size(s)</td>
<td colspan="3"><label>
<select name="size" size="1" multiple="multiple" class="test" id="size">
<option>0</option>
<option>2</option>
<option>4</option>
<option>6</option>
<option>8</option>
<option>10</option>
<option>12</option>
<option>14</option>
<option>16</option>
<option>18</option>
<option>20</option>
<option>22</option>
<option>24</option>
<option>26</option>
</select>
</label></td>
</tr>
<tr>
<td class="td">Condition</td>
<td colspan="3"><label>
<select name="Condition" class="test" id="Condition">
<option>New</option>
<option>Used</option>
</select>
</label></td>
</tr>
<tr>
<td class="td">Length</td>
<td colspan="3"><label>
<select name="Length" class="test" id="Length">
<option>Long</option>
<option>Short</option>
<option>Mid-Length</option>
</select>
</label></td>
</tr>
<tr>
<td class="td">Color</td>
<td colspan="3" class="td"><span id="sprytextfield5">
<label>
<input name="Color" type="text" class="test" id="Color" size="35" />
</label>
<span class="textfieldRequiredMsg">Required</span></span></td>
</tr>
<tr>
<td class="td">City</td>
<td class="td"><span id="sprytextfield4">
<label>
<input name="City" type="text" class="test" id="City" size="35" />
</label>
<span class="textfieldRequiredMsg">Required</span></span></td>
<td class="td"> </td>
<td class="td"> </td>
</tr>
<tr>
<td class="td">State</td>
<td colspan="3"><label>
<select name="State" class="test" id="State">
<option>AL</option>
<option>AK</option>
<option>AZ</option>
<option>AR</option>
<option>CA</option>
<option>CO</option>
<option>CT</option>
<option>DE</option>
<option>DC</option>
<option>FL</option>
<option>GA</option>
<option>HI</option>
<option>ID</option>
<option>IL</option>
<option>IN</option>
<option>IA</option>
<option>KS</option>
<option>KY</option>
<option>LA</option>
<option>ME</option>
<option>MD</option>
<option>MA</option>
<option>MI</option>
<option>MN</option>
<option>MS</option>
<option>MO</option>
<option>MT</option>
<option>NE</option>
<option>NV</option>
<option>NH</option>
<option>NJ</option>
<option>NM</option>
<option>NY</option>
<option>NC</option>
<option>ND</option>
<option>OH</option>
<option>OK</option>
<option>OR</option>
<option>PA</option>
<option>RI</option>
<option>SC</option>
<option>SD</option>
<option>TN</option>
<option>TX</option>
<option>UT</option>
<option>VT</option>
<option>VA</option>
<option>WA</option>
<option>WV</option>
<option>WI</option>
<option>WY</option>
</select>
</label></td>
</tr>
<tr>
<td class="td">Email</td>
<td colspan="3"><span id="sprytextfield3">
<label>
<input name="Email" type="text" class="test" id="Email" size="35" />
</label>
<span class="textfieldRequiredMsg">Required</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
</tr>
<tr>
<td height="26" class="td">Confirm Email</td>
<td colspan="3"><span id="spryconfirm1">
<label>
<input name="Confirm Email2" type="text" class="test" id="Confirm Email2" size="35" />
</label>
<span class="confirmRequiredMsg">Required</span><span class="confirmInvalidMsg">The values don't match.</span></span></td>
</tr>
<tr>
<td height="26" class="td">Photo(s)</td>
<td colspan="3"><label>
<input name="Photo" type="file" class="test" id="Photo" size="35" />
</label></td>
</tr>
<tr>
<td height="131" class="td">Additional Details</td>
<td colspan="3"><label>
<textarea name="Additional Details" cols="40" rows="6" class="test" id="Additional Details"></textarea>
</label></td>
</tr>
</table>
<p>
<label>
<input name="Submit" type="submit" class="test" id="Submit" value="Post" />
</label>
</p>
<input type="hidden" name="MM_insert" value="individual" />
</form>
SERVER BEHAVIOR
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;
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "individual")) {
$insertSQL = sprintf("INSERT INTO donations (postingTitle, `size`, condition, length, color, city, `state`, email, photo) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['Posting Title'], "text"),
GetSQLValueString($_POST['size'], "text"),
GetSQLValueString($_POST['Condition'], "text"),
GetSQLValueString($_POST['Length'], "text"),
GetSQLValueString($_POST['Color'], "text"),
GetSQLValueString($_POST['City'], "text"),
GetSQLValueString($_POST['State'], "text"),
GetSQLValueString($_POST['Email'], "text"),
GetSQLValueString($_POST['Photo'], "text"));
mysql_select_db($database_bridesmaidsrack_db, $bridesmaidsrack_db);
$Result1 = mysql_query($insertSQL, $bridesmaidsrack_db) or die(mysql_error());
$insertGoTo = "donations.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
header(sprintf("Location: %s", $insertGoTo));
DATABASE CONNECTION
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_bridesmaidsrack_db = "localhost";
$database_bridesmaidsrack_db = "bridesmaidsrack";
$username_bridesmaidsrack_db = "";
$password_bridesmaidsrack_db = "";
$bridesmaidsrack_db = mysql_pconnect($hostname_bridesmaidsrack_db, $username_bridesmaidsrack_db, $password_bridesmaidsrack_db) or trigger_error(mysql_error(),E_USER_ERROR);Hi David,
I did as you recommended. For good measure, I even changed the case of the letters to make sure that they coincide with exactly what's in the database. I still kept getting the same error message. So I deleted the recordset and attempted to recreate it. When I attempted to recreate the record set, I got the following error message: "RangeError: invalid array length". My codes are listed below:
Form:
<form method="POST" enctype="multipart/form-data" name="individual" class="individual" id="individual">
<table width="594" border="0" class="test">
<tr></tr>
<tr>
<td width="166" class="td">Posting Title</td>
<td colspan="3"><span id="sprytextfield1">
<label>
<input name="posting_title" type="text" class="test" id="posting_title" size="35" />
</label>
<span class="textfieldRequiredMsg">Required</span></span></td>
</tr>
<tr>
<td class="td">Size(s)</td>
<td colspan="3"><label>
<select name="size" size="1" multiple="multiple" class="test" id="size">
<option>0</option>
<option>2</option>
<option>4</option>
<option>6</option>
<option>8</option>
<option>10</option>
<option>12</option>
<option>14</option>
<option>16</option>
<option>18</option>
<option>20</option>
<option>22</option>
<option>24</option>
<option>26</option>
</select>
<span class="Text">To select multiple sizes, hold ctrl and select each size.</span></label></td>
</tr>
<tr>
<td class="td">Condition</td>
<td colspan="3"><label>
<select name="condition" class="test" id="condition">
<option>New</option>
<option>Used</option>
</select>
</label></td>
</tr>
<tr>
<td class="td">Length</td>
<td colspan="3"><label>
<select name="length" class="test" id="length">
<option>Long</option>
<option>Short</option>
<option>Mid-Length</option>
</select>
</label></td>
</tr>
<tr>
<td class="td">Color(s)</td>
<td colspan="3" class="td"><span id="sprytextfield5">
<label>
<input name="color" type="text" class="test" id="color" size="35" />
</label>
<span class="textfieldRequiredMsg">Required</span></span></td>
</tr>
<tr>
<td class="td">City</td>
<td class="td"><span id="sprytextfield4">
<label>
<input name="city" type="text" class="test" id="city" size="35" />
</label>
<span class="textfieldRequiredMsg">Required</span></span></td>
<td class="td"> </td>
<td class="td"> </td>
</tr>
<tr>
<td class="td">State</td>
<td colspan="3"><label>
<select name="state" class="test" id="state">
<option>AL</option>
<option>AK</option>
<option>AZ</option>
<option>AR</option>
<option>CA</option>
<option>CO</option>
<option>CT</option>
<option>DE</option>
<option>DC</option>
<option>FL</option>
<option>GA</option>
<option>HI</option>
<option>ID</option>
<option>IL</option>
<option>IN</option>
<option>IA</option>
<option>KS</option>
<option>KY</option>
<option>LA</option>
<option>ME</option>
<option>MD</option>
<option>MA</option>
<option>MI</option>
<option>MN</option>
<option>MS</option>
<option>MO</option>
<option>MT</option>
<option>NE</option>
<option>NV</option>
<option>NH</option>
<option>NJ</option>
<option>NM</option>
<option>NY</option>
<option>NC</option>
<option>ND</option>
<option>OH</option>
<option>OK</option>
<option>OR</option>
<option>PA</option>
<option>RI</option>
<option>SC</option>
<option>SD</option>
<option>TN</option>
<option>TX</option>
<option>UT</option>
<option>VT</option>
<option>VA</option>
<option>WA</option>
<option>WV</option>
<option>WI</option>
<option>WY</option>
</select>
</label></td>
</tr>
<tr>
<td class="td">Email</td>
<td colspan="3"><span id="sprytextfield3">
<label>
<input name="email" type="text" class="test" id="email" size="35" />
</label>
<span class="textfieldRequiredMsg">Required</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
</tr>
<tr>
<td height="26" class="td">Confirm Email</td>
<td colspan="3"><span id="spryconfirm1">
<label>
<input name="confirm_email2" type="text" class="test" id="confirm_email2" size="35" />
</label>
<span class="confirmRequiredMsg">Required</span><span class="confirmInvalidMsg">The values don't match.</span></span></td>
</tr>
<tr>
<td height="26" class="td">Photo(s)</td>
<td colspan="3"><label>
<input name="Photo" type="file" class="test" id="Photo" size="35" />
</label></td>
</tr>
<tr>
<td height="131" class="td">Additional Details</td>
<td colspan="3"><label>
<textarea name="Additional Details" cols="40" rows="6" class="test" id="Additional Details"></textarea>
<input name="hiddenField" type="hidden" id="hiddenField" value="Date" />
</label></td>
</tr>
</table>
<p>
<label>
<input name="Submit" type="submit" class="test" id="Submit" value="Post" />
</label>
</p>
</form>
Server Behavior
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;
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "individual")) {
$insertSQL = sprintf("INSERT INTO donations (posting_title, `size`, condition, length, color, city, `state`, email, photo) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['posting_title'], "text"),
GetSQLValueString($_POST['size'], "text"),
GetSQLValueString($_POST['condition'], "text"),
GetSQLValueString($_POST['length'], "text"),
GetSQLValueString($_POST['color'], "text"),
GetSQLValueString($_POST['city'], "text"),
GetSQLValueString($_POST['state'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['Photo'], "text"));
mysql_select_db($database_bridesmaidsrack_db, $bridesmaidsrack_db);
$Result1 = mysql_query($insertSQL, $bridesmaidsrack_db) or die(mysql_error());
$insertGoTo = "donations.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
header(sprintf("Location: %s", $insertGoTo)); -
PHP/mySQL code help please
Hi all,
Thanks to David Powers fab tutorial I am now well on my way to competeing my first dynamique website using PHP/mySQL, (thanks David ), however I am stuck on one particular area....can anyone please help?
I know that the mySQL database uses the format YYYY/MM/DD for dates, and that is fine. I've sorted out how to display in a more regular format (eg. 1st September 2011) for my application, but I am stuck on how to convert a more regular formatted date entered by the site user into the mySQL format.
Ideally I would like for the users entry or say either 1/9/11 or 1-9-11 (or something along those lines, to be recognised and displayed on the entry form, but to have a backend function that converts the data to mySQL format. I seem to be reading plenty of forum posts which say this can be done, but unfortunately I can't quite seem to fathom how, or where the code should sit. Would someone mind taking a look at my code page to actually identify what I need to insert, and equally as importantly...where!!!
Along these lines...is it possible to have a mini-calendar date picker that could be embedded next to the date entry field to ensure that a valid date is entered and in the correct format? Where could this be sourced?
Thanks in advance of some much needed help
MarkThis is becoming really frustrating for me (so god knows how I am to you!!!!), but I usually pick things up so fast and yet this whole PHP/SQL thing is eluding me!!
I can see (I think) how the code would work, but am struggling to see where it fits into place with my own Dreamweaver 'Update Record' code, as follows. I have spent a couple of days trawling through PHP.net and various other sites and forums before bringing my stupidity to the public domain, but I just can't seem to crack it.
This one last time then i'll leave you in peace??????
<?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;
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE gig_guide SET `date`=%s, town=%s, venue=%s, private_or_public=%s, start_time=%s WHERE `index`=%s",
GetSQLValueString($_POST['date'], "date"),
GetSQLValueString($_POST['town'], "text"),
GetSQLValueString($_POST['venue'], "text"),
GetSQLValueString($_POST['type'], "text"),
GetSQLValueString($_POST['start_time'], "text"),
GetSQLValueString($_POST['index'], "int"));
mysql_select_db($database_online, $online);
$Result1 = mysql_query($updateSQL, $online) or die(mysql_error());
$updateGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
header(sprintf("Location: %s", $updateGoTo));
$colname_updatePost = "-1";
if (isset($_GET['index'])) {
$colname_updatePost = $_GET['index']; -
I have a php mysql insert record application built in
dreamweaver. Is there a way to force or convert all inputted text
to all caps? I tried a style sheet text transform, but that doesn't
make the actual entry into the database all caps. Thanks.Admittedly though, that's pretty easy too.
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
==================
"Gary White" <[email protected]> wrote in message
news:[email protected]..
> On Tue, 13 Jan 2009 23:09:15 +0000, David Powers
<[email protected]>
> wrote:
>
>>Why? That means converting the data every time it's
displayed. If the
>>data is always required as uppercase, it makes more
sense to convert it
>>once at the time of storage.
>
> For the most part, I agree. However, there is the
possibility down the
> road, that they might want to use the data for something
other than the
> current ticker. In that case, it might display better in
mixed case. It's
> a lot easier to convert to all upper case for the
ticker, than to try to
> convert all upper case to mixed case.
>
> Gary
Maybe you are looking for
-
doe's any one have recovery disks for hp dv4-1435dx vista 32bit or know where to get some?
-
Can I get a replacement iphone set or servicing in Hong Kong for my iphone which is purchased in Singapore?
-
Upgrade path from old version of LabWin 3.1 and NIDAQ to WinXP system
Hello, I am trying to help folks at my old university lab recover from a Win95 PC failure with an old version of LabWindows, 3.1 (ca.~1997). They have a WinXP PC and have installed the old 3.1 software on this PC. My old projects will compile and
-
Service for vf02 permanently locks the invoice number
Hi, I have created one service for VF02 transaction as given in this path: default_host --->sap --->bc --->gui --->sap --->its --->VF02 I am calling this service in an external window browser from my Web Dynpro application. Problem is => if I cloase
-
Does Adobe work for Amazon?
Reading the problems people are having with Digital Editions I can only assume the complete lack of support from Adobe is planned to make people buy Kindles. I did. I will never buy an Adobe DRM eBook again. Ever. But then I only bought a cheap (£3)