Jump to content

taquitosensei

Members
  • Posts

    676
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by taquitosensei

  1. Barand,

     

    Yes, the names are the same.

     

    The action is to be processed by process.php.

     

    I changed it to text so I can see the values. That should be no brainer even for someone like me.

     

    That's why I said I am confused because every example I looked up followed same convention as the one I am following,

     

    That's also why I am wondering if the fact that I am trying to insert into a WordPress DB might have something to do with it,

     

    I have never done something like this in WordPress before.

    If you see the custname in your (now) text field. Then at the top of process.php the very first line you need to do var_dump($_POST); just to make sure your post data is making it to your process.php page. It sounds like the field(s) in your database can't be NULL and it's receiving a NULL value for at least $custname. 

  2. Yes, I tried that and the value coming out is NULL which is what is confusing me.

     

    In my original thread, I indicated that when I VIEW SOURCE on that page that passed the hidden form values to this process.php, I see the values.

     

    So, I guess my confusion is why is process.php page not recognizing those values?

     

    Every example I have looked at so far, suggests that I am doing it correctly but why it showing NULL value?

    So if you do the var_dump($_POST) as the very first line of process.php your other hidden fields have values, but custname is NULL? But if you view the source of the html page your value is there? What is the value?

  3. Hi,

     

    I want to devise a query to join 2 mysql data tables. What i want to achieve is to join both the tables in such a way that the result would display all the rows of TableOne with the single row of TableTwo appended to every single row of the result.

     

    TableOne has fields id, a, b, c and multiple rows.

    Data sample:

    1, a, b, c

    2, d, e, f

     

    TableTow has fields id, d, e, f and single row.

    Data sample:

    1, g, h, i, j, k

     

    Desired Output:

    a, b, c, g, h, i, j, k

    d, e, f, g, h, i, j, k

    Just use a join with no on statement.  

    select fields from tableone join tabletwo
  4.  echo "<div class=\"panel panel-primary\"><div class=\"panel-heading clickable\"><h3 class=\"panel-title\"><b>$title_list</b></h3>";
            echo "<small>$sublist</small><span class=\"pull-right\"><i class=\"fa fa-minus\"></i></span></div><div class=\"panel-sarabveer-table\"><table class=\"table\"><thead><tr><th>Time</th><th>Kirtani</th><th>MP3</th><th>Video</th></thead>";
    

    Is inside your database loop. You're creating a panel and table for every single result. If that's not what you're intending to do I would move this and line 97 outside of your database loop.

  5.  

    Hi,

     

    I am using below code, no matter what TO and FROM date i select, i am not able to export more than ~50K records to CSV from MYSQL db. 

     

    The code works but limited the records i can export. 50K is not a hard cut it keeps on varying.

     

    I am using the XAMPP, mysql version 5.6 (MariaDB).

     

    Whats wrong?

                           <?php
    
                                function getbetween($string, $from, $to) {
    
    
                                    $content = explode($from, $string);
    
                                    //print_r($content);
                                    $seccontent = explode($to, $content[1]);
    
    
                                    return $seccontent[0];
                                }
    
    
    
                                if (isset($_POST['submit'])) {
    
        $from = $_POST['from'];
        $to = $_POST['to'];
        $query = "select ticker, date_dt, open, high, low, close, wap, os_shares, ttq, total_trades, del_qty, sales, profit, op_assets from `stock_history` where date_t<='$to' and date_t>='$from'";
        $rows[] = array("ticker", "date_dt", "open", "high", "low", "close", "wap", "os_shares", "ttq", "total_trades", "del_qty", "sales", "profit", "op_assets");
    
        $sql = mysql_query($query);
        if (mysql_num_rows($sql) > 0) {
            while ($list = mysql_fetch_assoc($sql)) {
                $rows[] = $list;
            }
        }
        if ($rows != "") {
    
            $file = fopen("stock_history.csv", "w");
    
            foreach ($rows as $row) {
                fputcsv($file, $row);
            }
    
            fclose($file);
            echo '<a href="stock_history.csv" download>download</a>';
        }
    

    you might try append "a" instead of "w" so you're not writing to the beginning of the file every time. Not sure if its going through section more than once. The end of the function appears to be missing here. 

  6. The string looks okay as serialized data. More likely than not you have a value that's not the same length as the s: part. I would double check your test data to make sure these match.

    Ah! Your're right!

     

    I tried removing the first part - to try to make it look more json-like.

     

    This is the full string:

    a:12:{s:4:"navn";s:18:"Some data";s:5:"alder";s:33:"Some data";s:5:"email";s:17:"Some data";s:5:"kirke";s:45:"Some data";s:17:"praktisk-baggrund";a:1:{i:0;s:71:"Some data";}s:17:"instrument-toggle";a:1:{i:0;s:2:"Ja";}s:10:"instrument";s:22:"Some data";s:10:"min-stemme";s:35:"Some data";s:9:"kommentar";s:106:"Some data";s:19:"vaerelses-fordeling";s:0:"";s:18:"vegetar-eller-lign";s:0:"";s:15:"FUK-laereplaner";a:1:{i:0;s:0:"";}}

     

    Aha... so it may be serialized?

     

    I tried to unserialize(the string);

    And got: Error at offset 49 of 600

     

    Any ideas?

  7. This is an example and you'll have to make it work with your code but something like this would work.

    $items=array(1,2,3,4,5,6,7,;
    $html="<table>";
    $c=0;
    foreach($items as $item) {
    
    if($c==0) { 
         $html.="<tr>"; 
    }
    
    if($c%3==0) { 
         $html.="</tr>"; $c=0; 
    }
    
    $html.="<td>".$item."</td>";
    
    $c++; 
    }
    $html.="</table>"; 
    echo $html;
    
    
  8. I would create an ODBC connection to the database. Then use pdo_odbc. Judging from your phpinfo you'll need to turn on pdo_odbc. It should be in the core php on windows. By adding

    extension=php_pdo.dll

    and

    extension=php_pdo_odbc.dll

    to php.ini

     

    then take a look at

    http://www.sitepoint.com/using-an-access-database-with-php/

     

    EDIT - I just saw the part about asp 3.0 and this might not 100% apply to you.

     

    I have a website that runs on a hosted server with iis6 and php5.2.5 installed the website is written in asp3.0 (sorry) and fetches its data from an ms access database (again sorry).

    The database is stored on the physical path: D:\databases\database.mdb and there is no use of username/password.

    I want to create PDF files on the fly using FPDF so a database connection in php is the challenge, I've tried loads of examples from the web but unsuccesful so far.

    My phpinfo:

    http://www.freebits.nl/images/211screen1.jpg

    http://www.freebits.nl/images/424screen2.jpg

    Thanks in advance for the effort

    Paul

  9. time is the number of seconds since January 1 1970

     

    so just compare it.

    if(($timestamp2-$timestamp1) < 5) { 
      echo "Less than 5 seconds";
    } else { 
      echo "More than 5 seconds";
    }
    

     

    Hello, I'm trying to figure out how much is 5 seconds in time stamp.

     

    I know that this is 24 hours.

    <?php
    $timestamp = 1391021444;
    if($timestamp >= (time() - 60*60*24)) {
    echo "Less than 24 hours";
    } else {
    echo "More than 24 hours";
    }
    ?>

    But I want to try 5 seconds or maybe 10 seconds.

  10. you need an exit; after the header redirection.Without more info I think that will take care of it. Also...use code tags. It will make it much easier for people to read.

    if(mail($email,$subject,$messag2,$from)){ 
      header("Location: ../thank-you.html"); 
      exit;
    }
    

     

    Okay, so when I hit submit, it goes to /php/contactus.php instead of /thank-you.html, but it still displays the content of the /thank-you.html page

     

    I'm not sure what I'm doing wrong, and It's been eating me alive for a few hours. I know it's something simple that I'm overlooking. Here's the code....

     

    The code functions properly, otherwise. It sends one email to "$email" and it sends two copies of just the data posted to the other emails.

    It just doesn't direct to the "thank you" page.

     

    ----

     

    <?php

    $subject = "Thanks For Connecting With Me!";
    $from = "email@email.com";
    $fromName = "Name Here";
    $name = $_POST["name"];
    $email = $_POST["email"];
    $region = $_POST["region"];
    $notes = $_POST["notes"];

    $message1 = "Prospect Name: " . $name . "\nProspect Email: " . $email . "\nProspect Phone: " . $phone . "\nProspect Region: " . $region . "\nProspect Notes: " . $notes
    ;

    $message2 = "blah, blah, blah";


    if(mail($email, $subject, $message2, $from)){
      header("Location: ../thank-you.html");
    }else{
      echo "Message was not sent!";
    }

    mail("email1@gmail.com", "Prospect Contact Info", $message1, $from);
    mail("email2@gmail.com", "Prospect Contact Info", $message1, $from)


    ?>

  11.  

    I know this topic has been hit, I've read answers to similar issues between this site and stackoverflow but for some reason it doesn't seem to want to work and I feel like I'm missing a very small part of the puzzle.

    The error I'm getting is that the variable "pass" is not found.

     

    index.php

     

    <?php
    $lifetime = 86400;
    session_set_cookie_params($lifetime, '/');
    session_start();
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Web Survey</title>
                    <link href="styles.css" rel="stylesheet"></link>
    <style type="text/css">
    body {padding-top: 115px;}
    .main p {margin-left: 45px;}
                    h3 {margin-left:45px;}
    </style>
    </head>
    <body>
    <h1>Appendix D:</h1>
    <h1>Text</h1>
    <div class="main">
      <p class="intro">Text</p>
    <form action ="images.php" method="post">
             <h3><input type="submit" name="Submit" value="Begin" class="button"/>  Code:
                            <input type="text" name="pass" size="2"/><br />
                            <?php
                                if (isset($_POST['Submit'])) {
                                    $_SESSION['pass'] = $_POST['pass'];
                                }
                            ?>
    </h3>
    </form>
    </div>
    </body>
    </html>
     
    images.php
     
    <?php
        session_start();
        if ($_SESSION['pass'] == 00001) {
        $_SESSION['version'] = "version1"; }
        else if ($_SESSION['pass'] == 00002) {
        $_SESSION['version'] = "version2"; }
        else if ($_SESSION['pass'] == 00003) {
        $_SESSION['version'] = "version3";}
        $version = $_SESSION['version'];
        $picture1 = "images/".$version."/1.jpg";
        $picture2 = "images/".$version."/2.jpg";
        $picture3 = "images/".$version."/3.jpg";
        $picture4 = "images/".$version."/4.jpg";
    ?>
    <head>
    <title>Text</title>
    <link href="styles.css" rel="stylesheet">
    </head>
    <body>
    <center>
    <img src="" name="Rotating" id="Rotating" width=800 height=700>
    </center>
    <script language="JavaScript">
    var ImageArr1 = new Array("<?php echo $picture1; ?>","<?php echo $picture2; ?>","<?php echo $picture3; ?>","<?php echo $picture4; ?>");
    var ImageHolder1 = document.getElementById('Rotating');
    
    
    function RotateImages(whichHolder,Start)
    {
    var a = eval("ImageArr"+whichHolder);
         var b = eval("ImageHolder"+whichHolder);
         if(Start>=a.length)
            Start=0;
         b.src = a[Start];
         window.setTimeout("RotateImages("+whichHolder+","+(Start+1)+")",2500);
    }
      RotateImages(1,0);
      setTimeout(function(){window.location.href='form1.php'},10000);
      </script>
    </body>
    </html>
     
    I'm still learning php, I went through the Mike Murach php book, it's pretty good but doesn't really seem to help that much in this area.  It seems that when I post the index.php form, it should store the variable in the session using
                                if (isset($_POST['Submit'])) {
                                    $_SESSION['pass'] = $_POST['pass'];
    so that I can call it in images.php.  For some reason, though, 'pass' doesn't seem to be stored at all.  What step am I missing?

     

    It won't exist the first time you go to the page. As soon as you submit your form it will. So you'll need to check that your for has been submitted before trying to process $_POST['pass'].

     

    Something like

    if(isset($_POST['yourfieldname'])) { 
       // do your processing here 
    }
    
  12. if you are assembling the javascript on the server this should probably look more like...

    $calendar.= '<td onclick=showinfo("'.$year.'","'.$month.'","'.$list_day.'"); class="calendar-day_used">'.$list_day.'</td>';
    

    Hi

     

    I created php function that creates table. I want to create onclick evant on <td> that calls php function showinfo($year,$month,$day). Variable $list_day is inserted when table is generated(local variable for function).  Variables $year,$month are global variables.

     

    This is how I created <td>:

    $calendar.= '<td onclick=showinfo($year,$month,'.$list_day.'); class="calendar-day_used">'.$list_day.'</td>';
    

    This is what is generated from above code:

    <td onclick="showinfo($year," $month,="" 21);="" class="calendar-day_used2">21</td>
    

    What am I doing wrong???

     

    Thanks in anvance

  13. It means you're either not initializing your $DBH or it's not actually an object.

     

    I am writing a function to grab and count how many times a certain value is used in a table but get this error,

    Fatal error: Call to a member function query() on a non-object in C:\wamp\www\Rachels\includes.php on line 61
    

    I have tried looking up the error and found that it sometimes occurs when a variable is out of scope. I am passing my connection through the scope so I do not think that is the issue. My code is as follows 

    function getTagCount($inTagId=null, $inTagName=null, $DBH) {
        
        //Make the connection and grab all the tag's TAG TABLE HAS TWO FIELDS id and name
                $stmt = $DBH->query("SELECT * FROM tags");
                $stmt->execute();
                
                //For each row pulled do the following
                foreach ($stmt->fetchAll() as $row){
                    //set the tagId and tagName to the id and name fields from the tags table
                    $tagId = $row['id'];
                    $tagName = $row['name'];
                    
                    //Next grab the list of used tags BLOG_POST_TAGS TABLE HAS TWO FILEDS blog_post_id and tag_id
                    $stmt2 = $DBH->query("SELECT * FROM blog_post_tags");
                    $stmt2->execute();
                    $blogTagList = array();
                    $blogTagList = $stmt2->fetchAll();
                    $tagCount = array_count_values($blogTagList);
                    //Print the following list 
                    echo '<li><a href="popular_tags.php?=' . $tagId . '" title="' . $tagName . '">' . $tagName . '(' . $tagCount[$tagId] . ')</a></li>';
                //End of loop - start again
                }
                
    }
    
  14. you could use session_set_save_handler to override session handling then run code when the session is destroyed. 

     

    How can you run a query or a piece of code when a session ends or the user exits the browser with out logging out? 

     

    Thanks. 

     
     
    <?php
     
    session_start();
    include('C:\inetpub\wwwroot\connect.php');
    $provider_id = $_SESSION['provider_id'];
    $sql2 = "INSERT INTO provider_submits
    (provider_sub) values( '$provider_id')";
    $result2 = sqlsrv_query($link, $sql2); 
     
     
     exec('c:\\dblocal\\notes.bat'); ?>
     
    
  15. Usually that means it's not an array. Try print_r($custexp2);   to make sure it contains what you expect it to.

     

    Here is my code: 

    $marketingvalueOutput = ""; 
            foreach($marketingimportance2 as $marketingimportance){ 
                $marketingvalueOutput .= "<input type=\"radio\" class=\"radio\" name=\"marketingimportance[]\" value=\"". $marketingimportance ."\">". $marketingimportance ."  \r";   
            } 
    $marketingvalueOutput .= ""; 
    		
    $custexpOutput = ""; 
            foreach($custexp2 as $custexp){ 
                $custexpOutput .= "<input type=\"radio\" class=\"radio\" name=\"custexp[]\" value=\"". $custexp ."\">". $custexp ."  \r";   
            } 
    $custexpOutput .= ""; 
    
    $marfuOutput = "";
            foreach($marfu2 as $marfu){ 
                $marfuOutput .= "<input type=\"radio\" class=\"radio\" name=\"marfu[]\" value=\"". $marfu ."\">". $marfu ."  \r";   
            } 
    $marfuOutput .= "<br />"; 
    
    $custexpoptionsOutput = "";
            foreach($custexpoptions2 as $custexpoptions){ 
                $custexpoptionsOutput .= "<input type=\"checkbox\" class=\"checkbox\" name=\"custexpoptions[]\" value=\"". $custexpoptions ."\">". $custexpoptions ."  \r";   
            } 
    $custexpoptionsOutput .= "<br />"; 
    
    
    $outsourceoptionsOutput = "";
            foreach($outsource2 as $outsource){ 
                $outsourceoptionsOutput .= "<input type=\"checkbox\" class=\"checkbox\" name=\"outsource[]\" value=\"". $outsource ."\">". $outsource ."  \r";   
            } 
    $outsourceoptionsOutput .= "<br />"; 
    
    

    Here are the two errors I'm getting:

     

    Warning: Invalid argument supplied for foreach() in C:\wamp\www\survey\page_3.php on line 135
    Notice: Undefined variable: custexp2 in C:\wamp\www\survey\page_3.php on line 135
     
    Line 135 is the second foreach loop which says foreach($custexp2 as $custexp).
     
    Thanks

     

  16. you need to use == otherwise you're changing the value to TRUE

    if($showlog ==True)

     

    even better use if($showlogo)  That checks for true/false

    Hi there all,

     

    Slowly getting back into PHP after a long hiatus from any coding. Here is a quick piece of code that I put together, to display a logo depending on whether a variable is true or false, but it doesn't seem to be working. 

    if ( $showlogo = TRUE ) {
    $logo = "<img src=\"logo.png\" \>";
    } elseif ( $showlogo = FALSE ) {
    $logo = "";
    }
    echo $logo;

    This code is located in is called template.php. Each page on the website, so for example index.php, calls this template using the include function and those pages are where the variable $showlogo are set.

     

    Could anyone advise me on why it may not be working?

    Thanks!

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.