Jump to content

scotch33

Members
  • Posts

    36
  • Joined

  • Last visited

    Never

Posts posted by scotch33

  1. hi,

     

    I'm trying to set an item's visibilty based on whether it has been used before.  I have got to the stage where, if an item is used I write to a database and save the user's id, the artcle id and a 'lock id'.  Then using a foreach I am scrolling through the articles to check whether they have been viewed, setting  a session and then doing an if statement to show if the session says it's ok.  That's the theory.  ;-)

     

    In practice although I am getting the right callbacks from the database (a variable called lock_id shows the number of the database entry if there is an entry or '0' if there is not) I seem to be having trouble then setting the Session accordingly.  However lock ID is correctly showing as a different number.  Here's the code...

     

    if( isset($params['article_id']) )
    {
      $article_id = (int)$params['article_id'];
    }
    
    global $gCms;
    $feusers = $gCms->modules['FrontEndUsers']['object'];
    if( $feusers )
      {
          $uid = $feusers->LoggedInId();
          $user_data = $feusers->GetUserProperties($uid);
    }
    
    echo "The user ID is ".$uid;
    echo "<br />The article ID is ".$article_id;
    
    $article_lock =  mysql_query("SELECT lock_id FROM cms_module_news_lock
    WHERE user_id = '$uid' AND  news_id = $article_id");
    
    $article_lock_row = mysql_fetch_array($article_lock);
    $article_lock = (int)$article_lock_row['lock_id'];
    echo "<p>Lock ID:".$article_lock."</p>";
    
    if ($article_lock > 0) {
    $_SESSION['locked'] = "locked";
    } else {
    $_SESSION['locked'] = "unlocked";
    }
    

  2. hi there,

     

    here is my query -

    $affiliateresult = ("SELECT nov_main_firstname, nov_main_surname, nov_main_coname, nov_main_id, nov_affiliate_code FROM nov_affiliate_code, nov_main_account WHERE nov_affiliate_code.nov_affiliate_id = nov_main_account.nov_main_id");
    

    and then on line X i have the following -

    while ($affiliaterow = mysql_fetch_array($affiliateresult)) { some code }
    

     

    I have been into phpmyadmin and tested the sql in the query window and it resuklts in what i want, but when it is in my own code as above it is giving me the following

     

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/novusta1/public_html/admin_affiliates.php on line X

     

    I have been staring at this for an hour now and cannot work out what I am doing wrong - if anyone can help I would be very grateful.

     

    Thanks!

  3. I am having some trouble with getting 'include' working.  I have a new dedicated server running Apache 2.0.63 and PHP 5.2.6. 

     

    Local includes on the same domain are running ok, but remote includes are throwing a problem.  On the many sites we plan to host on this servber we use a central 'webmaster' page called as an include from a specific site (also on the same server).  Thus I need to edit the PHP.ini and /or recompile the PHP with the appropriate modules to do one of the following...

     

    1 (ideally) - allow includes from any site that is held on this dedicated server

    2.  allow includes from specified websites

    3.  simply allow remote includes

     

    Can anyone point me at the right settings to get one of these options running and solve my problem?

     

    Thanks very much!

  4. ok- that had some effect, but the error is still appearing.  the code below includes the settign of the integer.

     

    	settype($_SESSION['member_show_amount'], 'integer');
    $amount = $_SESSION['member_show_amount'];
    echo gettype($amount);
    
    // select the right type of user and amount of records to show
    if ($_SESSION['member_show_type'] == "active") {
    	  $adult_summary =  mysql_query("SELECT *
    FROM hav_main_account WHERE hav_main_active = '2' LIMIT 1, '$amount'");
    } elseif ($_SESSION['member_show_type'] == "suspended") {
    $adult_summary =  mysql_query("SELECT *
    FROM hav_main_account WHERE hav_main_active = '1' LIMIT 1, '$amount'");
    } else {
    $adult_summary =  mysql_query("SELECT *
    FROM hav_main_account LIMIT 1, '$amount'");
    }

     

    The results I am getting now, are the error below - the '25' it mentions is the number i am using to test and the word integer is from the gettype command b4 the sql query starts.

     

    integer
    
    error performing query: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 ''25'' at line 2

  5. Well this is an included file.  Line 2 of the file that includes it is

     

    session_start();

     

    line 2 of the file itself is just html as below

     

      <div class="box_top_left"><img src="../sitelook/box_tcorner_left.gif" width="63" height="60" /></div><div class="box_top_right"><img src="../sitelook/box_tcorner_right.gif" width="10" height="60" /></div><div class="box_bottom_left"><img src="../sitelook/box_bcorner_left.gif" /></div><div class="box_bottom_right"><img src="../sitelook/box_bcorner_right.gif" /></div>

     

    Also - if i take out '$amount' and use a number, it works as one would expect.

  6. Hi there,

     

    Thanks for that, but I am still getting an issue -

     

    The problem is -

     

    "error performing query: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 ''25'' at line 2"

     

    With the folllowing code (expanded to show all code in section in case anything else in it is causing the issue)...

     

    	// select the right type of user and amount of records to show
    if ($_SESSION['member_show_type'] == "active") {
    	  $adult_summary =  mysql_query("SELECT *
    FROM hav_main_account WHERE hav_main_active = '2' LIMIT 1, '$amount'");
    } elseif ($_SESSION['member_show_type'] == "suspended") {
    $adult_summary =  mysql_query("SELECT *
    FROM hav_main_account WHERE hav_main_active = '1' LIMIT 1, '$amount'");
    } else {
    $adult_summary =  mysql_query("SELECT *
    FROM hav_main_account LIMIT 1, '$amount'");
    }
    // end select the right type of user and amount of records to show

  7. I am trying to LIMT results for a query based on the amount of results that a user wishes to see - I am saving the amount the user wishes to see to a session variable, then trying to call it into a sql quey - but I cannot work out the syntax to do thjis - each time I try to build the query, it fails.  The code below is what I thought it should be (the session mentioned being a number...

     

    // select the right type of user
    $adult_summary =  mysql_query("SELECT *
    FROM hav_main_account WHERE hav_main_active = '2' LIMIT 1, '$_SESSION[member_show_amount]'");
    // end select the right type
    

     

    Can anyone help?

     

    Thanks.

     

  8. Hi there,

     

    I am having a bit of bother with sending a pdf as an attachment to an automated e-mail send to customers requesting  a brochure.  I have the mail and attachment working but when I try to open the pdf it says it cannot recognise the filetype.  I have looked around and everywhere I have looked the content type for PDF as an attachemnt is 'application/pdf'.  I have copied my code below - if anyone can see where I am going wrong I would appreciate the info.

     

    Thanks!

    John

     

     

    $headers = "From: info@newmaticelevators.com \r\n";
    $headers .= "Reply-To: info@newmaticelevators.com \r\n";
    $headers .= "Bcc:  \r\n";
    $recipient = $_SESSION['email'];
    $subject   = "Your brochure request from the Newmatic Elavators website";
    
    $bound_text =  	"antelope2574017";
    $bound = 	"--".$bound_text."\r\n";
    $bound_last = 	"--".$bound_text."--\r\n";
    
    $headers .=  	"MIME-Version: 1.0\r\n"
    	 	     		."Content-Type: multipart/mixed; boundary=\"$bound_text\"";
    
    $message .=  	"If you can see this MIME than your client doesn't accept MIME types!\r\n"
      					.$bound;
    
    $message .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n"
      		."Content-Transfer-Encoding: 7bit\r\n\r\n".
    	"<html>
    	<head>
    	<title>A brochure request from the Newmatic Elevators website</title>
    	</head>
    	<body><p>Dear ".$_SESSION['title']." ".$_SESSION['surname']."</p>
    	<p>You requested a brochure from the Newmatic elevators website.</p><p>Your brochure was requested as a PDF and is attached to this e-mail.  Should you have any futher requests please feel free to contact us on the details below.</p><p>Yours sincerely<br /><br />The Newmatic Elevators Team.</p>The Stag House<br />
    Wooburn Town<br />
    High Wycombe<br />
    Buckinghamshire<br />
    HP10 0PN<br />
    <br />
    Phone: 01628 523977<br />
    Fax: 01628 529130<br />
    <a href='mailto:info@newmaticelevators.com'>info@newmaticelevators.com</a></body></html>\r\n"
      	.$bound;
    
    $file =  file_get_contents("http://www.newmaticelevators.com/pdfs/NE_brochure.pdf");
    
    $message .=  	"Content-Type: application/pdf; name=\"NE_brochure.pdf\"\r\n"
      	."Content-Transfer-Encoding: base64\r\n"
      	."Content-disposition: attachment; file=\"NE_brochure.pdf\"\r\n"
      	."\r\n"
      	.chunk_split(base64_encode($file))
      	.$bound_last;
    
    mail($recipient,$subject,$message,$headers);
    // end send a confirmation to the requester
    header('Location: http://www.newmaticelevators.com/download/brochure_request_completed.php');

  9. Hi there,

     

    I am in the process of creaing my first image using the GD library and imagettftext.  I have got so far, but now hit a stumbling block.

     

    The process is as follows...

     

    User answers choices to create the text of a letter.

    Letter variables added to image?get

    Image called from page.

     

    I have got it all working fine apart from getting text to start on newlines when it reaches the end of a section.

     

    I have 2 issues -

     

    1.  I don't get how to set a boundary for text that tells it to word wrap when it reaches a point on the page.

    2.  I can't get the text to start a newline with either \n or <br> in the image - however, I can get it to start newlines if I look at the get text in the url. 

     

    I have scaled down a copy of the image here so you can see what i am getting so far - http:www.webserverworld.co.uk/letter.jpg

     

    I have looked around on the web and have seen some references to wordwrapping and tried to implement them but so far have had no luck.  If anyone can point me in the right direction on this, I would very much appreciate it.

     

    The code I am using thus far is below.

    <? 
    // Set the content-type
    header("Content-type: image/jpeg");
    
    // Create the image
    $im = imagecreatefromjpeg("santa_letter.jpg");
    
    // Create some colors
    $black = imagecolorallocate($im, 0, 0, 0);
    
    // The text to draw
    $greeting = $_GET['greeting'];
    $p1 = $_GET['p1'];
    $p2 = $_GET['p2'];
    $p3 = $_GET['p3'];
    $user = $_GET['user'];
    $pass = $_GET['pass'];
    
    // Replace path by your own font path
    $font = dirname(__FILE__).'/FGWurth.ttf';
    
    // Add the text
    imagettftext($im, 40, 0, 200, 900, $black, $font, $greeting);
    imagettftext($im, 40, 0, 200, 1100, $black, $font, $p1);
    imagettftext($im, 40, 0, 200, 1300, $black, $font, $p2);
    imagettftext($im, 40, 0, 200, 1500, $black, $font, $p3);
    imagettftext($im, 40, 0, 200, 1800, $black, $font, $user);
    imagettftext($im, 40, 0, 200, 1880, $black, $font, $pass);
    
    // array imagettftext ( resource $image, float $size, float $angle, int $x, int $y, int $color, string $fontfile, string $text )
    
    imagejpeg($im);
    imagedestroy($im);
    ?> 
    
    

  10. Hi there,

     

    I'm trying to create an image using imagettftext - at the moment I am just trying to get some basic image to work and then I plan to do stuff with it.

     

    I have grabbed example code from a php site as below...

     

    <? // Set the content-type
    header("Content-type: image/png");
    // Create the image
    $im = imagecreatetruecolor(400, 30);
    // Create some colors
    $white = imagecolorallocate($im, 255, 255, 255);
    $grey = imagecolorallocate($im, 128, 128, 128);
    $black = imagecolorallocate($im, 0, 0, 0);
    imagefilledrectangle($im, 0, 0, 399, 29, $white);
    // The text to draw
    $text = 'Testing...';
    // Replace path by your own font path
    $font = 'arial.ttf';
    // Add some shadow to the text
    imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
    // Add the text
    imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
    // Using imagepng() results in clearer text compared with imagejpeg()
    imagepng($im);
    imagedestroy($im);
    ?>

     

    However when I try to view it at http://www.havebeengood.com/memberpages/layout/images/letter.php, the result is this message - "The image “http://www.havebeengood.com/memberpages/layout/images/letter.php” cannot be displayed, because it contains errors."

     

    I have uploaded a copy of arial.ttf to the directory so that ref is correct

     

    If I try to create the image WITHOUT imagettftext - the image displays ok.

     

    I have put a php(info) file up to check all and have the following set in my GD library -

     

    GD Support 	enabled
    GD Version 	2.0 or higher
    FreeType Support 	enabled
    FreeType Linkage 	with freetype
    FreeType Version 	2.1.10
    T1Lib Support 	enabled
    GIF Read Support 	enabled
    GIF Create Support 	enabled
    JPG Support 	enabled
    PNG Support 	enabled
    WBMP Support 	enabled

     

    All seems ok - but its not working!  can anyone help me as to why this could be?

     

    Thanks!

  11. Hi there,

     

    I have just got a new dedicated server and need to setup PHP to work with mysql on it.  Now it comes pre-installed with php, my sql and REDHAT.  I have checked the PHPO config and can see that the problem I have (found whilst trying to install some software that wouldn't install because "Mysql extension" is not switched on) is that in the .configure php command 'without mysql' is set.  I am  guessing that by changing this command to 'with mysql' i'll be able to turn on the php ability to work with mysql and thus solve the prob.  So my question is how do i do that?  If anyone can point me at some help where I can learn about how to change the configure command in apache (if that is right?), then I would appreciate it!

     

    Thanks!

     

    John.

  12. Hi,

    I am getting this -

    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 'invoiceno='123456', amount='23.00', name='test', email='john@john.co.uk', phone=' at line 3

    when using the following code -

    [code] $sql_insert = "INSERT INTO payment_records SET
    rand_code='$randcode'
    invoiceno='$invoiceno',
    amount='$amount',
    name='$name',
    email='$email',
    phone='$phone',
    companyname='$companyname',
    billingaddress='$billingaddress',
    billingpostcode='$billingpostcode',
    addresschange='$addresschange'";[/code]

    apparently the version of mysql has recently been upgraded to 4.3.10 - I have tried to find refernce to any difference in comands but haven't had a lot of luck.  Can anyone point me in the right direction?
  13. Hi,

    I am trying to write to a database using the code below.  however when this code is in the page I am getting the following error -

    Parse error: syntax error, unexpected $end in /home/c/m/cmsinstituteofli/public_html/bespokepay2/completed.php on line 78

    where the line '78' is in fact the closing tag of the html. 

    If I remove the code, the page works fine.  Can anyone help


    <?
    $connector = mysql_connect('localhost', '[USERNAME]', '[PASSWORD]');
    mysql_select_db('[DATABASENAME]', $connector);

    $randcode = md5(rand(1,9999).time().str_shuffle("qwertyuiop12345"));
    $invoiceno = $_COOKIE[invoiceno];
    $amount = $_COOKIE[amount];
    $name = $_COOKIE[name];
    $email = $_COOKIE[email];
    $phone = $_COOKIE[phone];
    $companyname = $_COOKIE[companyname];
    $billingaddress = $_COOKIE[billingaddress];
    $billingpostcode = $_COOKIE[billingpostcode];
    $addresschange = $_COOKIE[addresschange];

    $sql_insert = "INSERT INTO payment_records SET
    rand_code='$randcode'
    invoiceno='$invoiceno',
    amount='$amount',
    name='$name',
    email='$email',
    phone='$phone',
    companyname='$companyname',
    billingaddress='$billingaddress',
    billingpostcode='$billingpostcode',
    addresschange='$addresschange'";
    if (@mysql_query($sql_insert)) {
        echo "Thank you for your order <br />A receipt has been sent to your e-mail address.<br />The order process is now finished.";
    $result =  mysql_query("SELECT * FROM payment_records WHERE randcode='$randcode'");
    if (!$result) {
    exit('<p>error performing query:'.mysql_error().'</p>');
    }
    $row = mysql_fetch_array($result);
    ?>
  14. Thanks Orio.
    This looks ideal.  One question - whilkst reading the instructions it mentions
    [quote]If running from shell, put this above the <?php  "#! /usr/bin/php -q"  without the quotes!!![/quote]

    It further mentions that if I am going to cron this and keep the database safe,. then this is teh best option.  Am i right in assuming the running from shell, is running from the root folder rather than the public_html folder?

    Thanks!

    John.
  15. [code] $result =  mysql_query('SELECT * FROM dvd_orders');
    if (!$result) {
    exit('<p>error performing query:'.mysql_error().'</p>');
    }
    $row = mysql_fetch_array($result);
    <h2>Orders Summary</h2>
    <?
    echo "<table class='orderresults_table' border='0' cellspacing='0' cellpadding='0'>
    <tr class='orderresults_heading'>
    <td class='orderresults_inv'>Inv No</td>
    <td class='orderresults_name'>Name</td>
    <td class='orderresults_date'>Date</td>
    <td class='orderresults_amount'>Amount</td>
    <td class='orderresults_button'>More...</td>
    </tr>";
    while ($row = mysql_fetch_array($result)) {
    echo "<tr class='orderresults_entry'>";
    echo "<td class='orderresults_inv'>".$row['inv_no']."</td>";
    echo "<td class='orderresults_name'>".$row['cust_name']." ".$row['cust_surname']."</td>";
    echo "<td class='orderresults_date'>".$row['date']."</td>";
    echo "<td class='orderresults_amount'>£".$row['order_total']."</td>";
    echo "<td class='orderresults_button'><form id='detail' name='detail' method='post' action='detail.php'>
    <input name='inv_no' type='hidden' value='".$row['inv_no']."' />
    <input name='submit' type='submit' value='details' />
        </form></td>";
    echo "</tr>";
    }
    echo"</table>"
    ?>
    [/code]
  16. Hi there,

    Thanks!  that was a useful article - however, I have done a little with headers before and the first thing I did check was if there was anything there.  There is nothing at all in the page before the <?php start, not even white space.

    Your second point - I am not sure where to even start with error checking on this so iof anyone can give me a pointer or point me at articales related I would appreciate it.

    the database has only one usename and password, which are the ones I am using to get to the database.  they are also used on all the other pages in the site accessing the database and there is no problem with them.

    Any further help would be appreciated.

    Thanks again.
  17. I am trying to list the rows from a table in my page using the following code.  The odd thing is that in the MYSQL admin there is sets 109 - 126 yet this code only shows sets 110 - 126.  There is no other code on the page that limits what is showing.  if i delete all entries and start again I am always showing one less in the mage than the admin is showing.  any ideas?  thanks!
    John

    [code]<?
    echo "<table class='orderresults_table' border='0' cellspacing='0' cellpadding='0'>
    <tr class='orderresults_heading'>
    <td class='orderresults_inv'>Inv No</td>
    <td class='orderresults_name'>Name</td>
    <td class='orderresults_date'>Date</td>
    <td class='orderresults_amount'>Amount</td>
    <td class='orderresults_button'>More...</td>
    </tr>";
    while ($row = mysql_fetch_array($result)) {
    echo "<tr class='orderresults_entry'>";
    echo "<td class='orderresults_inv'>".$row['inv_no']."</td>";
    echo "<td class='orderresults_name'>".$row['cust_name']." ".$row['cust_surname']."</td>";
    echo "<td class='orderresults_date'>".$row['date']."</td>";
    echo "<td class='orderresults_amount'>£".$row['order_total']."</td>";
    echo "<td class='orderresults_button'><form id='detail' name='detail' method='post' action='detail.php'>
    <input name='inv_no' type='hidden' value='".$row['inv_no']."' />
    <input name='submit' type='submit' value='details' />
        </form></td>";
    echo "</tr>";
    }
    echo"</table>"
    ?>[/code]
  18. Hi there,

    I am trying to provide a customer with a backup button to my sqldump a database.  the code (kindly provided in [url=http://www.devpapers.com/article/55]http://www.devpapers.com/article/55[/url] is...
    [code]
    $db_host = "localhost";
    $db_name = "mydbasename";
    $db_user = "mydbaseusername";
    $db_pass = "mydbasepassword";

    mysql_connect($db_host,$db_user,$db_pass);
    @mysql_select_db($db_name) or die("Unable to select database.");

    function datadump ($table) {

        $result .= "# Dump of $table \n";
        $result .= "# Dump DATE : " . date("d-M-Y") ."\n\n";

        $query = mysql_query("select * from $table");
        $num_fields = @mysql_num_fields($query);
        $numrow = mysql_num_rows($query);

        for ($i =0; $i<$numrow; $i++) {
      $result .= "INSERT INTO ".$table." VALUES(";
        for($j=0; $j<$num_fields; $j++) {
        $row[$j] = addslashes($row[$j]);
        $row[$j] = ereg_replace("\n","\\n",$row[$j]);
        if (isset($row[$j])) $result .= "\"$row[$j]\"" ; else $result .= "\"\"";
        if ($j<($num_fields-1)) $result .= ",";
      } 
          $result .= ");\n";
        }
        return $result . "\n\n\n";
      }

    $dvd_orders = datadump ("dvd_orders");
    $products = datadump ("products");

    $content = $dvd_orders . $products;

    $file_name = "MySQL_Database_Backup.sql";
    Header("Content-type: application/octet-stream");
    Header("Content-Disposition: attachment; filename=$file_name");
    echo $content;
    exit;
    [/code]

    However I am now getting the following results...

    Warning: Cannot modify header information - headers already sent by (output started at /home/pathto/backup.php:11) in /home/pathto/backup.php on line 42 Warning: Cannot modify header information - headers already sent by (output started at /home/pathto/backup.php:11) in /home/pathto/backup.php on line 43 # Dump of dvd_orders # Dump DATE : 19-Dec-2006 INSERT INTO dvd_orders VALUES("","","","","","","","","","","","","","","","","","","",""); INSERT INTO dvd_orders VALUES("","","","","","","","","","","","","","","","","","","",""); INSERT INTO dvd_orders VALUES("","","","","","","","","","","","","","","","","","","",""); INSERT INTO dvd_orders VALUES("","","","","","","","","","","","","","","","","","","",""); INSERT INTO dvd_orders VALUES("","","","","","","","","","","","","","","","","","","",""); INSERT INTO dvd_orders VALUES("","","","","","","","","","","","","","","","","","","",""); INSERT INTO dvd_orders VALUES("","","","","","","","","","","","","","","","","","","",""); # Dump of products # Dump DATE : 19-Dec-2006 INSERT INTO products VALUES("","","","");

    At the moment there is no other code on the php page other than the function - do i need to put some kind of header in to tell the page that it is just executing this script?

    Thanks!

    John
×
×
  • 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.