PHP / MySQL - printing a Variable in a Table cell for a while in a loop

Hello

The attached code works very well. When running loop a while, in an HTML table, it prints the value of 'votes_up' of a MySQL database for each "$row2".

However, in a HTML table cell, I would like to print "votes_up" less any other value, called "votes_down." I imagine that the first step would be to create a variable equal to "votes_up" under "votes_down". But I do not know how to print this new variable for each "$row2" in the MySQL database. How can I do this?

Thanks in advance,

John

.oO (ArizonaJohn)

> The attached code works very well. In an HTML table, it prints "votes_up".
> value of a database MySQL for each "$row2" generated by a 'while' loop
>
> However, in a HTML table cell, I would print "votes_up" less another
> value called "votes_down" I guess the first step would be to create a
> variable equal to "votes_up" under "votes_down". But I don't know how to print
> this new variable for each "$row2" in the MySQL database. How can I do this?
>
> Thanks in advance,.
>
> John
>
"> print"". $row2 ['votes_up']."";

$votes_diff = $row2 ["votes_up"] - $row2 ["votes_down"];
print '.$votes_diff";

or

print '.". ($row2 ['votes_up']-$row2 ['votes_down']). »";

HTH
Micha

Tags: Dreamweaver

Similar Questions

  • How can I get the data in the foreign key?  PHP/mysql

    I managed to create registration, log-in and results pages appear for accounts of client with PHP/Mysql/Dreamweaver 8. I have another page for more information to be contained in a child table, I used the Insert Wizard to create. I can't make it work. I get either a foreign key cannot be null error or a foreign key constraint.

    If I include the foreign key in the form on the page, I can manually enter the appropriate identification number, and it works. How to automatically enter the id into the foreign key column?

    I got the authentication of users using e-mail, password and user type.

    Thanks for your help

    When someone connects, Dreamweaver creates a session variable called $_SESSION ['MM_Username"]. Use this session variable to create a recordset object to get the ID of the user, who can then be entered in the child table's foreign key field.

    Dreamweaver automatically updates the code for recordsets immediately above the DOCTYPE declaration, then you will need to move above the code for the server behavior insert record. So it must be in the following order:

    1. Recordset to get the user ID
    2. Insert the record to the child table
  • association table update with post boxes php/mysql table

    OK, I have a dynamic site for the checkboxes are dynamically added to the page database. the name of check boxes affect one table "checkbox []". now my $_Post ['checkbox'] will be an array. now I want to take this picture and make a loop for which updates my table once for each variable in the table, but it is not working and I am perplexed...

    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
      for ($i=0;$i<count($_POST['SpecificationEquipped']);$i++) {
       $updateSQL = sprintf("UPDATE TestersSpecifications SET SpecificationEquipped=%s WHERE TesterModel=%s AND SpecificationID=%s",
             GetSQLValueString(isset($_POST['SpecificationEquipped'][$i]) ? "true" : "", "defined","1","0"),
             GetSQLValueString($_POST['TesterModel'], "text"),
             GetSQLValueString($_POST['SpecificationID'][$i], "int"));
     
      mysql_select_db($database_ampacin1_ampac, $ampacin1_ampac);
      $Result1 = mysql_query($updateSQL, $ampacin1_ampac) or die(mysql_error());
      }
    }
    

    I don't know how make table works how the code is to "set". Anyone who thinks that they can tell me the best way to do it?

    Impression of SQL to see what is generated is the best way to solve problems with dynamically generated queries.

    It is not easy to understand exactly what you're trying to do. However, it might help you to solve the problem if you understand what does the following section of code:

    GetSQLValueString(isset($_POST['checkbox']) ? "true" : "", "defined","1","0")
    

    When a form is submitted, the value of a checkbox control is submitted through array $_POST only if the box is checked. Let's say you have a box like this:

    
    

    If the box is checked, the value of $_POST ["accept"] is "o". If the check box is disabled, $_POST ["accept"] is NOT defined. It is not empty, null, or something like that. There is simply not.

    That Dreamweaver verifies if the variable check box exists (isset()). If so, it inserts 1 in the database field. Otherwise, it inserts 0.

    The problem is that you have created a check box group, using a table. Let's say you have 10 check boxes in this group, if only 5 are selected, your table will contain only 5 Articles.

    Depending on how you configure things, I think you must have differently named checkboxes for each record that must be inserted into the database. You can do it with a counter and a loop:

    
      
    
    

    If you don't know in advance the number of items will be in your loop, you can use $i as the value for a field hidden once the loop is completed. This will allow you to browse your update queries, using the value of the hidden field to control the loop and using a meter to change the name of the boxes.

    for ($i = 1; $i < $_POST['count']; $i++) {
    // other stuff
    GetSQLValueString(isset($_POST["cb_$i"]) ? "true" : "", "defined","1","0")
    // other stuff
    }
    
  • Calling functions within an echo in PHP/Mysqli statement

    I have a table written in php that is filled with a mysqli result set.

    It draws on the table and it fills from the result set table, as below, using a properly figurative connection:

    <? PHP / * DRAWN AS AN ARRAY * /.

    echo "< table border = 0 > ';

    While ($row = mysqli_fetch_array ($resultset, MYSQLI_NUM))

    / * $s = (date (a/m/Y ", strtotime ($row [1])"))-it's the conversion of reference * /.

    echo "< tr > < td > $row [0]: $row [4]: $row [2] < table >.

    < td rowspan = 15 >

    < img = name-"picspot\" src =------------.

    width =------"300\" height =-"240\" alt =------"image."

    $row [10] >

    < table >

    < /tr >

    < b >

    < td > pictured: $row [1] < table > / * < td > pictured: $s < table > * /

    < /tr >

    / * more lines go here * /.

    < /table >.

    ? >

    Copy the following code works properly and produced a table in the correct format and value with the data in the table as shown:

    table1.JPG

    $row [1] contains a timestamp in the format 2003-10-17 00:00:00 and prints it in the table next to the word "photo".

    I need to convert this date using something like:

    $s = (date (a/m/Y ", strtotime ($row [1])"))

    If I include this in the echo statement it prints only the above function instead of the date.

    If I do the conversion date immediately after the stated time, and then include

    < td > pictured: $s < table > instead of < td > pictured: $row [1] < table >

    that works very well, but he kills as all the other outputs of the $resultset table.

    table2.JPG

    I'm obviously something wrong, but can not understand.

    Run out of two calls to the application and storing the first $row [1] in a variable, converting it to a date and by printing on a second print request run, looks like overkill, I can't find a solution.

    Can you?

    All suggestions welcome.

    Howard Walker

    After much research, I had to resort to a second query as follows:

    $getID = mysqli_fetch_assoc (mysqli_query ($conn, "SELECT photodate FROM table WHERE ref = $t"));

    $pdate = $getID ["photodate"];

    $pdate = (date (a/m/Y ', strtotime ($pdate)));

    .

    .

    .

    On the photo: $pdate

    produce a correct output.

    Moral - if you work in this long enough there are take a way!

    Have fun!

    Howard Walker

  • Display a session variable in a table of shopping cart.

    I try to view a session variable generated from a connection to a shopping cart page so that I can then filter the content of the cart by user.  The cart is a table in a MYSQL/PHP database.

    I have very little experience in php/mysql, so I'm probably doing something wrong.

    1. At the present time, the user must connect before adding a product to the cart - this has been implemented in the behaviors panel.
    2. A form has been implemented on my product page so that when the user clicks on the "buy" button, the product_id, quantity of the item etc is inserted in the table of shopping cart.
    3. I tried to use the bindings panel to add also the user name which I believe has been implemented as a session variable in the login page and included in a hidden field on the form, but when I look at the table in phpMyAdmin, that the following text is displayed in my column of variabe session:
    4. < br / > < b > view < /b >: Undefined variable: _SESSION in < b > C:\wamp\ www\boutique_wines \wine.php < /b > on line < b > 114 < /b > < br / >
    5. Line 114 reads as follows: < input name = "username" type = "hidden" id = "username" value = "<?" PHP echo $_SESSION ['MM_Username'];? ">" / >

    Help, please

    Mark

    Mark,

    Basically, you are saying this: my car does not start. I want it to start, but when I put the key in all I see is a lightweight control engine. Help, please.

    It is difficult to help you if you show us what is under the hood.

    I guess that the session is not started on the page, resulting in an undefined variable error message. Also, it is not a good idea to insert a field hidden dynamics of information if you are just using the hidden field to insert information into a database. Form fields can be hacked. What is to stop someone to visit your page, copy the source of your form, changing the value of the hidden field, download the form altered on their server and submitting the form to your processing script? Bypass the hidden field method and simply insert the session username variable directly in the database via a query to avoid manipulation of the input field.

  • Unknown column in the PHP/MySQL field list

    I created a feedback form for our airshow site and it works great. I now create some pages of the review, which are also working well, then

    ... I decided to improve one of the review pages and now it does not work... sigh.

    We ask stakeholders to provide their zip code and I have a vision showing the number of responses by postcode, this works very well and can be seen here http://www.hollisterairshow.com/feedback-results.php , so I decided to improve it by adding the City / State based on zip code. I created a new table called 'postcodes' and imported a list of zip codes and city / state info - all the 42,000 + of them.

    The PHP/MySQL, who works is illustrated below

    <? PHP
    Connect MySQL

    $query = "SELECT zip, COUNT (zip) ZIP GROUP BY feedback";

    $result = mysql_query ($query) or die (mysql_error ());

    Print results
    While ($row = {mysql_fetch_array ($result))}
    echo $row ["zip"]. " ". $row ['COUNT (zip)'];
    echo "< br / > ';
    }
    ? >

    As I am now faced with two tables, I thought that I had to add the name of the table in any field, so I added the names of tables and fields to the new table so

    I changed the PHP / MySQL as follows

    <? PHP
    Connect MySQL

    $query = 'SELECT feedback.zip, COUNT (feedback.zip), zipcodes.citystate OF feedback codes postal WHERE feedback.zip = zipcodes.zipcode GROUP BY feedback.zip';

    $result = mysql_query ($query) or die (mysql_error ());

    Print results
    While ($row = {mysql_fetch_array ($result))}
    echo $row ['feedback.zip']. " ". $row ['COUNT (feedback.zip)']. " ". $row ['zipcodes.citystate'];
    echo "< br / > ';
    }
    ? >

    and it fails when I run it says ' Unknown column 'feedback.zip' in "field list '"

    I would be grateful any suggestion on this, I am new on this PHP/MySQL stuff.

    Thank you

    Tony

    Tables listed in the From clause must be separated by commas. As it is, it is evaluated as an alias.

  • PHP Mail with session variables

    Here is the code for an email to collect page, which sends two session variables (email and postal code) to an email_sub.php page (data are inserted in MySQL). After submitting the form, I get the email_sub.php? page where this code works normally

    <? PHP echo $_SESSION ['email'];? >

    <? PHP echo $_SESSION ['postal code'];? >

    However, when the email is sent, the "subject" and the "To" is successfully sent, but not the variables $email and $zipcode.

    From:
    Zip code:

    If I hard code for values of and Zip, they appear in the email. It seems therefore that session variables are not available at the email_sub.php page.

    If anyone can point me in the right direction for a fix, I'd be very happy to suggestions.

    email_collect.php

    <? php require_once('Connections/connMan.php');? >
    <? PHP
    session_start();
    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 "set":
    $theValue = ($theValue! = "")? $theDefinedValue: $theNotDefinedValue;
    break;
    }
    Return $theValue;
    }

    $editFormAction = $_SERVER ['PHP_SELF'];
    If (isset {}
    $editFormAction. = « ? ». htmlentities($_SERVER['QUERY_STRING']);
    }

    If ((isset($_POST["MM_insert"])) & & ($_POST ["MM_insert"] == "form1")) {}
    $email = $HTTP_POST_VARS ['email'];
    session_register ("email");
    $zipcode = $HTTP_POST_VARS ["zipcode"];
    session_register ("zipcode");
    $insertSQL = sprintf ("INSERT INTO email_list (e-mail, postal code) VALUES (%s, %s)," ")
    GetSQLValueString ($_POST ['email'], "text").
    GetSQLValueString ($_POST ['PostalCode'], "int"));

    @mysql_select_db ($database_connMan, $connMan);
    $Result1 = mysql_query ($insertSQL, $connMan) or die (mysql_error ());

    $insertGoTo = "email_sub.php";
    If (isset {}
    $insertGoTo. = (strpos ($insertGoTo, '?'))? « & » : « ? » ;
    $insertGoTo. = $_SERVER ['QUERY_STRING'];
    }
    header (sprintf ("location: %s", $insertGoTo));
    }

    @mysql_select_db ($database_connMan, $connMan);
    $query_rsEmailer = "SELECT * from email_list";
    $rsEmailer = mysql_query ($query_rsEmailer, $connMan) or die (mysql_error ());
    $row_rsEmailer = mysql_fetch_assoc ($rsEmailer);
    $totalRows_rsEmailer = mysql_num_rows ($rsEmailer);
    ? >
    < ! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional / / IN" "http://www.w3.org/TR/html4/loose.dtd" > ""
    < html >
    < head >
    < title > em touch all the Camps of Baseball < /title >
    < meta http-equiv = "Content-Type" content = text/html"; charset = iso-8859-1 ">"
    < link href = "assets/taylor.css" rel = "stylesheet" type = "text/css" > "
    < script type = "text/JavaScript" >
    <!--
    function MM_findObj (n, d) {//v4.01
    var p, i, x;  if(!d) d = document; If ((p = n.IndexOf ("?")) > 0 & & parent.frames.length) {}
    d = parent.frames [n.Substring(p+1)] .document; n = n.Substring (0, p) ;}
    If (!) () x = d [n]) & & copyrights) x = d.all [n]; for (i = 0;! x & & i < d.forms.length; i ++) x = d.forms [i] [n];
    for (i = 0;! x & & d.layers & & I < d.layers.length; i ++) x = MM_findObj (n, d.layers [i] .document);
    If (! x & & d.getElementById) x = d.getElementById (n); Return x;
    }

    function MM_validateForm() {//v4.0
    var i, p, q, n, test, num, min, max, errors = ", args = MM_validateForm.arguments;
    for (i = 0; I <(args.length-2); I += 3) {test = args [i + 2]; val = MM_findObj(args[i]);
    If (val) {n = val.name; if ((val=val.value)! = "") {}}
    If (test.indexOf ('isEmail')! =-1) {p = val.indexOf (' @');}
    If (p < 1 | p ==(val.length-1)) errors +='-' + nm + "must contain an e-mail address. \n » ;
    } Else if (test! = 'R') {num = parseFloat (val);
    If (isNaN (val)) errors +='-' + nm + 'must contain a number. \n » ;
    If (test.indexOf ('inRange')! = - 1) {p = test.indexOf (': ');}
    min = test. Substring(8,p); Max = test. Substring (p + 1);
    If (num < min | max < num) errors +='-' + nm + must contain a number between "+ min +" and "+ max +".. " \n " ;
    }} ElseIf (test.charAt (0) == 'R') errors += '-' + nm + ' is required. \n " ; }
    } If (errors) alert ("the following error occurred: \n'+errors");
    document. MM_returnValue = (error == ");
    }
    ->
    < /script >
    < / head >

    < body >
    < are method = "post" name = "form1" action = "<?" PHP echo $editFormAction;? > ">"
    < table width = "325" align = "center" >
    < tr valign = 'of basic">
    < td colspan = "2" align = "left" >
    < h1 class = "subtitle" > join our Email list < / h1 >
    < p > please fill in boxes and click on & quot; Send. & quot; This information is kept secret and is intended for the exclusive touch of < strong > Hank Manning em all Camps of Baseball < facilities > in order to send you the latest happenings on our calendar.
    < /p >

    < p > < / p >
    < table >
    < /tr >
    < tr valign = 'of basic">
    < td align = "right" valign = "middle" nowrap > < p > E-mail: < /p > < table >
    < td align = "left" valign = "middle" > < input name = "email" type = "text" onBlur = "MM_validateForm ('email',", 'RisEmail'); " return document. MM_returnValue"size ="32"value ="Email address"> < table >
    < /tr >
    < tr valign = 'of basic">
    < td align = "right" valign = "middle" nowrap > < p > code postal: < /p > < table >
    < td align = "left" valign = "middle" > < input name = "PostalCode" type = "text" onBlur = "MM_validateForm ('postcode',", 'RisNum'); " return document. MM_returnValue' size = '32' value = 'postal Code' > < table >
    < /tr >
    < tr valign = 'of basic">
    < td align = "right" > < input type = "reset" name = "Reset2" value = "Reset" > < br >
    < input type = "submit" value = "send" > < table > ' "
    < td > < table >
    < /tr >
    < /table >
    < input type = "hidden" name = "MM_insert" value = "form1" >
    < / make >
    < p > < / p >
    < / body >
    < / html >
    <? PHP
    mysql_free_result() will free all memory associated with the result identifier result.

    mysql_free_result() only needs to be called if you are concerned about how much memory is used for queries that return large result sets. All associated result memory is automatically freed when the script is completed.
    mysql_free_result ($rsEmailer);
    ? >

    email_sub.php

    <? PHP session_start(); It connects to the existing session

    email sent

    / / [email protected] , [email protected]
    mail (' [email protected], [email protected]', "Join Email List", "from: $email\r\n Zip: $zipcode");
    ? >
    < ! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional / / IN" "http://www.w3.org/TR/html4/loose.dtd" > ""
    < html >
    < head >
    < title > em touch all the Camps of Baseball < /title >
    < meta http-equiv = "Content-Type" content = text/html"; charset = iso-8859-1 ">"
    < link href = "assets/taylor.css" rel = "stylesheet" type = "text/css" > "
    < / head >

    < body >


    < table width = "280" border = "0" cellspacing = "0" cellpadding = "0" >
    < b >
    < td colspan = "2" > < img src = "images/manning_logo.jpg" width = "426" height = "64" > < table > "
    < /tr >
    < tr valign = "top" >
    < td colspan = "2" > < p > < / p >
    < p align = "left" > thank you very much for sending your email and zip code. < /p >
    < table width = "350" border = "0" cellspacing = "0" cellpadding = "0" >
    < b >
    < td width = "69" > < p align = "right" > email: < /p > < table >
    < td width = "281" > < p align = "left" > <? PHP echo $_SESSION ['email'];? > < / p > < table >
    < /tr >
    < b >
    < td > < p align = 'right' > postal code: < /p > < table >
    < td > < p align = "left" > <? PHP echo $_SESSION ['postal code'];? > < / p > < table >
    < /tr >
    < / table > < p align = "left" > This information will be stored in our database exclusive use < facilities > < strong > Hank Manning em all the Baseball Camps Touch, which respects and protects your privacy. < /p >
    < table >
    < /tr >
    < b >
    < td width = "407" align = "left" > < a href = "javascript:window.close();" "> close this window < /a > < table >
    < td width = "19" > < p > < / p > < table >
    < /tr >
    < /table >
    < p > < / p >
    < p > < / p >
    <? PHP
    end the session so that I could see new variables because they are passed in the development
    session_destroy();? >
    < / body >
    < / html >

    sbudlong wrote:

    I made the change you suggested but the showsFrom:Zip still E-mail: without values for the variables. Is there a problem with the session?

    It seems that you do not use session variables when you send the mail:

    mail('[email protected], [email protected]',
    'Join Email List',
    "From: $email\r\n Zip: $zipcode");
    

    Change to this:

    mail('[email protected], [email protected]',
    'Join Email List',
    'From: ' . $_SESSION['email'] . "\r\n Zip: " .
    $_SESSION['zipcode']);
    
  • In PHP, MySQL, MEASURE date manipulation

    I have a datetime stored in MySQL I recover from the operation of update uninstall via the following statement:

    $last_date = KT_escapeForSql ($tNG-> getColumnValue ("last_kpi_gen_date"), $tNG-> getColumnType ("last_kpi_g en_date"));

    Now, I want to add 1 day, 7 days, or a month to date.  I try to use mktime but it seems he wants it in order of date different (h, m, s, a-m-j), I tried the strtotime function and the function date to reformat the $last_date, but it doesn't seem to work.

    Is there an easy way to add days to a date variable extracted from a database of MySQL using uninstall getColumnValue?

    Hi, I'm doing this way:

    You can CHECK for MySQL with time + 8 hours:

    create view DATETIME as
    SELECT DATE_FORMAT (DATE_ADD (now (), 8 HOURS APART), '%A - %m - %j % H: % i: %s') as DT_add8hour;

    Or with + 8 days:

    create view DATETIME as
    SELECT DATE_FORMAT (DATE_ADD (now (), 8 DAYS APART), '%A - %m - %j % H: % i: %s') as DT_add8day;

    This option stores CURRENT time value allways more apart. So you can use this update another table colums duration you want. Works perfectly with DW + MEASUREMENT + PHP + MySQL

    Here are several Date and time functions

    I hope this helps you!

    Post edited by: asdaf1234

  • help with php mysql connect script

    OK guys im new to php mysql and I try inserting form information in my database. IM using a sitepoint script in which I went through the tutorial made some experiences of myself and it worked...

    but now I get this error that I can't understand...

    Command error: you have an error in your syntax SQL; consult the manual corresponding to your version of the server MySQL for the right syntax to use near 'order product SET = ' 1', 'average' = size, color is ", amount = '1' at line 1

    Here is the page
    http://vaughntucker.com/imagecon/hats.php

    and this is the script
    <? PHP
    default page view
    connect to the database
    $dbcnx = @mysql_connect ('p3nl41mysql7.secureserver .net', 'imagecon', ' Dub * boss_1');
    If (! $dbcnx) {}
    echo "< p > unable to connect to the '. 'database server at this time." < /p > ";
    Exit();

    }

    Select database
    If (! @mysql_select_db ('imagecon')) {}
    exit (' < p > cannot locate the ".")
    "database at this time. < /p >");
    }

    MySQL Query add joke
    If (isset($_POST['submit'])) {}
    $product = 1;
    $size = $_POST ["size"];
    $color = $_POST ['color'];
    $quan = $_POST ['quantity'];
    $sql = "INSERT INTO command TOGETHER
    product = "$product."
    size = "$size."
    Color = "$color"
    quantity = "$quan"
    Date = CURDATE () ';
    } else {}
    ECHO 'no data sent ";

    }
    If (@mysql_query ($sql)) {}
    echo "< p > your order has been sent. < /p > ";
    } else {}
    echo ' error < p > order process: '.
    mysql_error(). / '< p > ';
    }



    ? >

    Thanks in advance

    Murray * ACE * has written:
    > $sql = "INSERT INTO command TOGETHER."
    "> product ='". $product. "',
    "> size ='". $size. "',
    "> color ='". $color. "',
    ' > quantity = ' ". $quan. "',

    No, this is not what is causing the problem. It is the use of 'order' as
    the name of the table. The order is an SQL reserved word. Either the name of the table
    should be changed, or the query INSERT rewritten as follows:

    $size = mysql_real_escape_string($_POST['size']);
    $color = mysql_real_escape_string($_POST['color']);
    $quan = mysql_real_escape_string($_POST['quantity']);
    $sql = 'INSERT INTO 'order' SET
    product = 1,.
    size = "$size."
    Color = "$color"
    quantity = $quan,
    'date' = CURDATE () ';

    Note that I surrounded order and date with backticks. I also have
    $product, was deleted because it has a fixed value. I removed the quotes from
    around $quan, because the numbers should not be quoted in SQL queries.

    The changes I did assume that magic quotes are disabled the
    Server. If they are on, you must also pass the variables $_POST
    stripslashes() like this:

    $size = mysql_real_escape_string (stripslashes($_POST['size']));
    $color = mysql_real_escape_string (stripslashes($_POST['color']));
    $quan = mysql_real_escape_string (stripslashes($_POST['quantity']);

    --
    Adobe Community Expert David Powers
    Author, "The Essential Guide to Dreamweaver CS4",
    "PHP Solutions" & "PHP Object-Oriented Solutions.
    http://foundationphp.com/

  • Unable to connect error 404 PHP/MySQL

    Wow, the learning curve is killing me. Yet another challenge. I use Dreamweaver CC and this tutorial http://www.adobe.com/devnet/dreamweaver/articles/setup_php.html

    I'm at this stage:

    1. Open comments.php . You must have a PHP page open in the Document window to create a MySQL connection.
    2. In the databases Panel (choose window > databases), click on the sign located on the Panel and select MySQL Connection.The MySQL connection dialog box appears.
    3. Type connTest as login name.
    4. For the MySQL server, type localhost. If you use MAMP ports by default on a Mac, use localhost:8889.
    5. For the user name, type phptestuser.
    6. Type the password that you chose for the phptestuser account in the password field.
    7. To the database, type php_test. Note: You need not precede the underscore with a backslash character here. It was inserted by phpMyAdmin in the previous section (see Figure 20) only because phpMyAdmin uses a query which allows wildcards.
    8. Click on Test.Dreamweaver tries to connect to the database. If the connection fails, follow these steps:
      • Check the server name, user name, and password.
      • Check the settings in the file that Dreamweaver uses to process dynamic pages (see specification of a Dreamweaver testing server).
      • Ensure that the web and MySQL server are both running.
      • Temporarily disable any firewall or security program. If the connection works, you must configure the security program to allow communication between Dreamweaver and MySQL.
    9. Click OK. The new connection appears in the data Panel.
    10. Expand connTest connection, and then expand the Tables branch. You will see the comments table in the database, you can expand to reveal the details of the columns in the table (see Figure 23).

    I can say that I followed this tutorial to the letter.

    As far as I know, XAMPP/php mySQL all running very well, the files are in the right place and everything should work. However when I type test, I get a 404 error. (Same error when I hit the select button).

    The problems on the 404 message are:

    1. There is no server running on the server test.

    Sure the testing server is running. Is there a way to test this, another that note that xampp is certainly running right now and I can connect to phpMYadmin without problem?

    2 test specified for this site server is not mapped with the http://localhost/php_test/_MMServerScripts/MMHTTPDB.php URL check that the URL prefix maps to the root of the site.

    UH... I'm sure that I put things where I was told to put them in the tutorial, but I'm lost right now where I should check that. A clue here? The files are where they are supposed to be, but maybe I entered something wrong? Except... I don't know what it might be or where to find it. Whatever IT is.

    Everything in the local files is fine.

    Thanks for your help!

    PS: Extra points to anyone who figures how to make copy/pasteable error messages! These guys are the bane of my life!

    Stop and restart the services he. Stop Xampp if still the same behavior. It should look like as below

  • calculate a php with a new variable class

    I don't know what a class is. I have already written page that has in place for the equations. I have made new variables to a new equation but get incorrect results, I basically need multiple / divide / subtract these classes pre-generated against my new variable

    That's what I have so far

    <? PHP

    $utilityHost = 21.0;

    $col4 is $option_two-amount_due_before - $option_two-> four_weeks_security - $option_two-> tax >;.

    $col5 = $col4 / $row_Recordset1 ["rental_price"];

    $col3 = $utilityHost * $col5;

    $col6 = $row_Recordset1 ["rental_price"] * $col5;

    ? >

    $col4 is the variable using the pre built classes.

    all these are in fact the echo in a table

    for example

    <? PHP

    echo ' £» number_format ($row_Recordset1 ['rental_price'] - $utilityHost);

    ? >

    <? PHP

    echo ' £» $utilityHost;

    ? >

    classes

    <? PHP

    require_once('.. / lib/PaymentOptionOne.php');

    require_once('.. / lib/PaymentOptionTwo.php');

    require_once('.. / lib/PaymentOptionThree.php');

    require_once('.. / lib/PaymentOptionFour.php');

    $rent = $row_Recordset1 ["rental_price"];

    If ($row_Recordset1 ['weekly_rate']! = 0.00)

    $rent = $row_Recordset1 ["weekly_rate"];

    $weeks = $row_Recordset1 ["weeks"] / 7;

    $query = "SELECT * from editprop WHERE prop_id = %s ';

    $query is sprintf ($query, GetSQLValueString ($row_Recordset1 ['prop_id'], "text"));.

    $results = mysql_query ($query);

    While ($Row = mysql_fetch_array ($Results))

    {

    $option_three_rent = $row ["rental_price_monthly"];

    If (Empty ($option_three_rent))

    {

    $option_three_rent = $rent;

    }

    }

    $option_one = new PaymentOptionOne ($rent, $weeks);

    $option_two = new PaymentOptionTwo ($rent, $weeks);

    $option_three = new PaymentOptionThree ($option_three_rent, $weeks);

    Thanks in advance

    > multiple my variable with classes that are already in place

    The classes are complex constructions that contain data structures and methods. You do not have multiple variable with a class - you can reference a variable within the class or object. What exactly is the problem you're having with it?

    This syntax should work (note that I use arbitrary variables):

    $col4 = $option_two-> amount_due_before * $col2

    I think that it is essential that you are familiar with coding object-oriented if you go to work with her.

    http://www.elated.com/articles/object-oriented-PHP-for-absolute-beginners/

  • PHP/MySQL relational database

    Hello

    I'm pretty new to php/MySQL. I'm stuck on how to make a cross-connection database.

    I have two tables 'users' and 'comments' and wants to set up a page that a user can see and edit the comments they made.

    So far, I tried to do an advanced Recordset, but all I managed to do is to display all records that share a user_id.

    I use dreamweaver CS5.5 and PHP and MySQL.

    Thanks in advance for your help

    Eddie

    This should be just a base query SELECT * FROM {comment-tbl} WHERE userid = $_SESSION ['user'].

    Do you use Cookies or Sessions at this point or you're simply trying to write this in a query without them?

  • Horizontal/vertical repeat region PhP/MySQL

    Hi guys,.

    I'm sure that this issue would have been requested many times before. If so, my apologies for the re - this announcement first.

    In any case, what I'm trying to do is create a repeat region that spans 4 columns and then repeat the rest in rows. For example, if I have 100 records in my table (MySQL), so I want to display in a table of 4 columns and 25 rows and (in reality, the number of records would be indeterminate, of course, but still records must be displayed on a 4 X line table column). 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

    For the moment, I have no problem with displaying the records vertically or horizontally (explicitly) by using the behavior 'repeat region. However, when I have the problem is with displaying records in a table like the one I described above.

    I use PS CS5 with PhP/MySQL.

    Can I still do this in server behavior "repeat region", using the If yes how?

    Otherwise, if not, how could I achieve this (ideally without using extensions)?

    Thanks in advance for any help and support,

    See you soon

    The Horizontal Looper to Tom Muck is perhaps something for you:

    http://www.Tom-Muck.com/extensions/

  • AS3 / PHP / MySQL - login form

    Hello

    I am creating the simplest example I can an AS3/PHP/MySQL interaction.  I want a Flash animation to check login/pass a user against a database.  I tested the PHP code and know that it is correct.  The problem must lie in his.  I traced everything to make sure that it shuts down correctly, but it is up under the names of variable $user, $passer... and some of the other garbage... not the values of the variables I wait... see below.

    The PHP code returns correctly what follows when tested in the browser: user = dan & pass = danpass & err = success!

    The variable traces $user, $pass, $err return the following Flash:

    undefined

    $pass

    $err ';


    echo $returnString;


    }


    ? >

    The following ActionScript code:

    import flash.events. *;

    import flash.net.URLLoader;

    import flash.net.URLRequest;

    import flash.net.URLVariables;

    import flash.net.URLRequestMethod;

    logbtn.addEventListener (MouseEvent.CLICK, login)

    function login ($e:MouseEvent) {}

    var myVariables:URLVariables = new URLVariables();

    var myRequest:URLRequest = new URLRequest ("login.php");

    myRequest.method = URLRequestMethod.POST;

    myRequest.data = myVariables;

    var myLoader:URLLoader = new URLLoader;

    myLoader.dataFormat = pouvez;

    myLoader.addEventListener (Event.COMPLETE, completeHandler);

    myVariables.user = loguser.text;

    myVariables.pass = logpass.text;

    myLoader.load (myRequest);

    function completeHandler(event:Event):void {}

    trace (Event.Target.Data.User);

    trace (Event.Target.Data.Pass);

    trace (Event.Target.Data.Err);

    }

    }

    And here is the PHP:

    <? PHP

    include_once "dbconnect.php";

    $user = $_POST ['user'];

    $pass = $_POST ['pass'];

    $sql = mysql_query ("SELECT * FROM users WHERE user = ' $user ' AND pass = '$pass'");

    $check = mysql_num_rows ($sql);

    If ($check > 0) {}

    $row = mysql_fetch_array ($sql);

    $user is $row ['user'];.

    $pass is $row ['pass'];.

    $err = ' Success! ';

    $returnString = "user = $user & pass = $pass & err = $err;

    echo $returnString;

    }

    ? >

    Nothing stands out as incorrect?  I went on that for probably 10 or 15 hours trying different variations, tweaks and reduce complexity.  Really, I'd appreciate any help you can offer!  Thank you.

    -Eric

    Hello

    you load the php file in the same folder, or localhost (running the SWF in a browser)?

    If being run from localhost, your system could deliver rather than run php scripts

  • PHP/MySql error message

    I posted this before and didn't get the answer I need, probably because I didn't post all my codes. I use PHP/MySql.  I created a Web site that has several forms.  When I conducted three of the forms, I get the below error messages:

    You have an error in your SQL syntax; consult the manual for your version of the MySQL server for the right syntax to use near ' condition, length, color, city, 'State', Email, Photo) VALUES ('29 ', ' 4',' used "in line 1.)

    I write the codes below.  I hope this time that I posted everything I should have so that I can get help.

    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 >
    < b >
    < td width = "166" class = 'td' > view < table > title
    < td colspan = "3" > < span id = "sprytextfield1" >
    < label >
    < input name = "Display title" type = "text" class = "test" id = "Display title" size = "35" / >
    < / label >
    < span class = "textfieldRequiredMsg" > required </span > < / span > < table >
    < /tr >
    < b >
    < td = 'td' class > price < table >
    < 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 > < table >
    < /tr >
    < b >
    < class td = 'td' > < table > format
    < td colspan = "3" > < label >
    < select name = "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 > < table >
    < /tr >
    < b >
    < class td 'td' = > status < table >
    < td colspan = "3" > < label >
    < select name = "Condition" class = 'test' id = 'State' >
    < option > new < / option >
    < option > used < / option >
    < / select >
    < / label > < table >
    < /tr >
    < b >
    < class td 'td' = > length < table >
    < td colspan = "3" > < label >
    < select name = "Length" class = 'test' id = 'Length' >
    Long < option > < / option >
    Short < option > < / option >
    < option > mid-length < / option >
    < / select >
    < / label > < table >
    < /tr >
    < b >
    < class td 'td' = > color < table >
    < 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 > < table >
    < /tr >
    < b >
    < class td 'td' = > city < table >
    < class td = 'td' > < span id = "sprytextfield4" >
    < label >
    < input name = "City" type = "text" class = 'test' id = 'City' size = "35" / >
    < / label >
    < span class = "textfieldRequiredMsg" > required </span > < / span > < table >
    < class td = 'td' > < table >
    < class td = 'td' > < table >
    < /tr >
    < b >
    < class td 'td' = > status < table >
    < 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 > OF < / option >
    < option > DC < / option >
    < option > FL < / option >
    < option > GA < / option >
    < option > HI < / option >
    ID < option > < / option >
    < option > HE < / option >
    IN < option > < / option >
    < option > HERE < / option >
    < option > KS < / option >
    < option > KY < / option >
    < option > THE < / option >
    < option > ME < / option >
    < option > MD < / option >
    < option > MY < / option >
    < option > e < / option >
    < option > MN < / option >
    < option > MS < / option >
    < option > MO < / option >
    < option > MT < / option >
    < option > NOT < / 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 > LAUGHED < / option >
    < option > SC < / option >
    < option > SD < / option >
    < option > TN < / option >
    < option > TX < / option >
    < option > c < / option >
    < option > VT < / option >
    < OPTION > < / option >
    < option > WA < / option >
    < option > WV < / option >
    < option > WI < / option >
    < option > WY < / option >
    < / select >
    < / label > < table >
    < /tr >
    < b >
    < class td 'td' = > Email < table >
    < 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 > < table >
    < /tr >
    < b >
    < height = "26" td class = 'td' > confirm Email < table >
    < 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 > < table >
    < /tr >
    < b >
    < height td = '26' class = 'td' > photo (s) < table >
    < td colspan = "3" > < label >
    < input name = "Photo" type = 'file' class = 'test' id = 'Photo' size = "35" / >
    < / label > < table >
    < /tr >
    < b >
    < height = '131' td class = 'td' > < table > Details
    < td colspan = "3" > < label >
    < textarea = cols "Additional Details" name = "40" lines "6" = class = 'test' id = "Détails" > < / textarea >
    < / label > < table >
    < /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" / >
    < / make >

    SERVER BEHAVIOR


    If (! function_exists ("GetSQLValueString")) {}
    function GetSQLValueString ($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
    {
    If (via 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 "set":
    $theValue = ($theValue! = "")? $theDefinedValue: $theNotDefinedValue;
    break;
    }
    Return $theValue;
    }
    }

    $editFormAction = $_SERVER ['PHP_SELF'];
    If (isset {}
    $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 ["'validation title"], "text").
    GetSQLValueString ($_POST ['size'], "text").
    GetSQLValueString ($_POST ["State"], "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 {}
    $insertGoTo. = (strpos ($insertGoTo, '?'))? « & » : « ? » ;
    $insertGoTo. = $_SERVER ['QUERY_STRING'];
    }
    header (sprintf ("location: %s", $insertGoTo));
    }

    CONNECTION TO THE BASE


    # 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);

    OK, so your initial problem was the condition of the word, because it is a reserved word for MySQL.

    Here is a list of the reserved words.

    http://dev.MySQL.com/doc/refman/5.1/en/reserved-words.html

    If you use a reserved word, you must place the accents around it like this...

    "condition."

    then MySQL knows you use it as a standard Word and he interprets not as command.

    OK now on the following problem.

    'Photo' column cannot be null

    When you have created your table in MySQL tells you that the photo field can not be empty. If you are forcing people to add a photo, then you need to do the checked field before the script runs / inserts. If you're ok with them NOT to add a photo, then you have to allow NULL values for this field in your table. This is a function that you would normally control via PHP MyAdmin or other MySQL database management software.

    Now, the last question:

    The Dynamic (form.action...) attribute is just how the FIELD itself will appear in SB (Server Behaivors) who is not the insertion of a plug.

    Record insertion as I said probably disappeared because some how you two when you shouldn't have one. So when we removed a DW (Dreamweaver) now think his party but is not. This can sometimes be corrected by opening the page again and closing or manually set or remove all SB side code, and then add the insertion of a plug anywhere. But at least you know what was the original problem so you can fix it after add it again.

Maybe you are looking for