R0bb0b 344 Posting Shark

Unless you want to pay an hourly rate I suggest reading this: http://www.w3schools.com/php/php_forms.asp and this: http://www.w3schools.com/php/php_mysql_insert.asp . If you have any questions about the process, those go here.

R0bb0b 344 Posting Shark

just curious, what happens when you put an

exit();

after the header() call?

If that doesn't solve the problem then put an

exit("End");

just before the header call and then view source after you run it to see if there is any white space or characters prior to the word "End" in the html source. If there is then you are, or something is, outputting content to the page prior to the header redirect attempt which means that headers have already been sent to the browser and a 302 is no longer possible at that point.

R0bb0b 344 Posting Shark

use mysql_num_rows

if (mysql_num_rows($result) == 0) {
    echo "No records found";
}
R0bb0b 344 Posting Shark

ya, but jquery just makes the who browser compatibility thing much easier.

R0bb0b 344 Posting Shark

I would use jquery keyup or keypress for that at

R0bb0b 344 Posting Shark

if this is solved, go ahead and mark it as solved. thx.

R0bb0b 344 Posting Shark

this worked perfectly for me. I kept testing and realized that you specifically need the bit with the ssl and the port. I did it exactly as it is shown here and it worked fine.
http://www.web-development-blog.com/archives/send-e-mail-messages-via-smtp-with-phpmailer-and-gmail/

R0bb0b 344 Posting Shark

red003.mail.apac.microsoftonline.com is an exchange address, not an smtp server. You can contact microsoft to find out what your smtp server address is or how to configure it or you can set up a standard email account through gmail or some other company that does provide smtp services. I would have no idea how to connect and send through exchange.

R0bb0b 344 Posting Shark

OK, that was an insane amount of code to send an email. I include "phpMailer/class.phpmailer.php" and here is my code. Tested and works. This really not all that much different than setting up an email client with smtp, it works the same way so I would read the documentation from your smtp provider and see if there are any catches or anything else is needed for the smtp server other than standard authentication.

<?php
require("phpMailer/class.phpmailer.php");
$objMail = new PHPmailer();
$objMail->SetLanguage("en", "phpmailer/language");
$objMail->From = "you@youremail.com"; // the email address that the email is from
$objMail->FromName = "your name"; // the name that the email is from
$objMail->Host = "your.smtpserver.com"; // the smpt host server
$objMail->Mailer   = "smtp"; // the protocol
$objMail->Password = "your_smtp_password"; // your smtp password for the server
$objMail->Username = "your_smtp_username"; // your user name for your smtp server, usually your email address
$objMail->Subject = "this is a test of phpmailer";
$objMail->SMTPAuth  =  "true"; // smtp requires authentication
$objMail->Body = "this is a test email, please do not repy";
$objMail->AddAddress("emailaddress@tosendto.com");  // the email address you want to send to
$objMail->AddReplyTo("you@youremail.com");  // the reply to email address
if (!$objMail->Send())
{
echo "There was an error in sending mail, please try again at a later time\n\n";
}
$objMail->ClearAddresses();
?>
R0bb0b 344 Posting Shark

Post your smtp code.

R0bb0b 344 Posting Shark

Any time I have used phpmailer in the past I have always used smtp. If you would rather use sendmail, I would go with the error that you are getting from phpmailer "Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs\kattendance\kmail.php on line 3" and do some research on that. It is a widely supported class and you should be able to get quite a bit of info on it. To use smtp you will need an smtp server and Try this example and see if it helps: http://phpcode.mypapit.net/sending-mail-using-smtp-with-phpmailer/26/

R0bb0b 344 Posting Shark

what is the most recent error in phpmailer

echo $objMail->ErrorInfo;
R0bb0b 344 Posting Shark

that depends on what you want out of it but for ajax and mysql, almost any hosting company will work.

R0bb0b 344 Posting Shark

You know, a good read might do you some good. I would start with something like this: http://articles.sitepoint.com/article/ajax-jquery

BTW: Jquery is a javascript library that makes ajax much easier but if you don't want to use Jquery the same concept applies. Find a good tutorial and spend a few hours on it.

R0bb0b 344 Posting Shark

You should go with a reputable one like Zend. Something that is going to continue to update years from now and stay with that one. You don't want to end up in a situation where you are trying to update php or apache and have it break, just to find out that if you want to update you have to move your entire business to a new framework. Either that or build your own so that you will know what parts of the code need to be modified in order to work with the latest versions of php or apache.

R0bb0b 344 Posting Shark

you need javascript. Jquery makes this real easy: http://flowplayer.org/tools/scrollable/index.html

R0bb0b 344 Posting Shark

I'm sure that they can but I'm also pretty sure that they won't.

R0bb0b 344 Posting Shark

I don't know what $var is but if you want the select box to preselect a value that is in the url then it should look like this:

$display_block .= " <form method=\"post\" action=\"$_SERVER[PHP_SELF]\">

      <p><strong>Select a client to View:</strong><br>
            		
     				 <select name=\"sel_id\">";
         
      while ($recs = mysql_fetch_array($get_list_res)) 
      { 
          //$clientID = $recs['clientID'];
          $id = $recs['id']; 
          $display_name = stripslashes($recs['display_name']); 

          $display_block .= '<option value="' . $id . '"' . (isset($_GET['sel_id']) && trim($_GET['sel_id']) == $id?' selected="selected"':'') . '> 
               $display_name</option>'; 
          } 

      $display_block .= " </select>";
R0bb0b 344 Posting Shark

personally, I would go with a database. Session data that large, even though it shouldn't hinder the server since it is just a flat file, does hinder the users experience if it gets too large because the server has to read the entire session file every time the page is loaded and the server has to overwrite the entire session file for every miniscule adjustment, where as with a database you can surgically adjust and get data only when necessary.

Same rule also applies to database stored sessions, I wouldn't do it mainly because the user's overhead required to get and overwrite even just one single character is a monster.

R0bb0b 344 Posting Shark

here you go:
url = http://yourdomain.com?selid[]=one&selid[]=two&selid[]=3

<?php

if(isset($_GET['selid']) && is_array($_GET['selid']) && count($_GET['selid']) > 0)
{
    echo '<select id="selid" name="selid">
    ';

    foreach($_GET['selid'] as $key=>&$value)
    {   
        echo '<option value="' . $key . '">' . $value . '</option>
        ';
    }   

    echo "</select>
    ";
        
}
?>
R0bb0b 344 Posting Shark

first thing that comes to mind is this:

$_SESSION['username'] == $username;
$_SESSION['name'] == $name;

should be:

$_SESSION['username'] = $username;
$_SESSION['name'] = $name;
R0bb0b 344 Posting Shark

so upon submission of this upload file, I assume that this is a standard form submission and the page refreshes. the server processes the file and then populates the values in this <div> tag.

If that's the case then you would want to somehow tap into the already written functionality of the cart to update the values on the server side so that the cart will display the correct values naturally as the developer intended.

Does this make sense, you don't want to reinvent the wheel if you don't have to and you don't want to prevent 10%(maybe a little exagerated) of users from using your cart because they don't have javascript enabled.

R0bb0b 344 Posting Shark

Does the book actually say "PHP 5/mySQL" in the title. That is horrible.

PLEASE!! do yourself a favor: http://www.wiley.com/WileyCDA/WileyTitle/productCd-0470413964.html

R0bb0b 344 Posting Shark

this is not tested but I am about 99% sure that it will work:

<html>
    <head>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>  
        <script type="text/javascript" language="javascript">
            var blnOpenStatus = false;

            $(document).ready(function()
            {
                $("#linkID").click(function()
                {
                    if(blnOpenStatus)
                    {
                        blnOpenStatus = false;
                        $("#BDInfo").hide();
                        $("#linkIDImg").attr("src","path/to/closed.jpg");
                    }
                    else
                    {
                        blnOpenStatus = true;
                        $("#BDInfo").show();
                        $("#linkIDImg").attr("src","path/to/open.jpg");
                    }
                });
            });
        </script>
    </head>
    <body>
        <a href="#" id="linkID"><img id="linkIDImg" src="path/to/closed.jpg" /></a>
        <!-- I would use a div here but it looks like you are using a table -->
        <table id="BDInfo" cellpadding="0" cellspacing="0" style="display:none;">
            <tr>
                <td>Backup Date:</td>
            </tr>
            <tr>
                <td>2010-12-01 09:09:31</td>
            </tr>
        </table>
    </body>
</html>
R0bb0b 344 Posting Shark

let's run some standard debugging.

throw an:

echo $sql . "<br />";

right after line 17 to show the actual query being sent to the database, then run that query against the database in phpMyAdmin or whatever database management system you are using. If that also gives you an error then it must be the query, if not then there is an issue with your connection or the way you are selecting the database.

I do know that php.net is strongly suggesting to avoid using the mysql_db_query function as they are depricating it as of 5.3. If you read http://us3.php.net/manual/en/function.mysql-db-query.php, near the top is a good example of the recommended way of connecting and running a query.

R0bb0b 344 Posting Shark

quoted from http://kyleschaeffer.com/best-practices/css-font-size-em-vs-px-vs-pt-vs/

1. “Ems” (em): The “em” is a scalable unit that is used in web document media. An em is equal to the current font-size, for instance, if the font-size of the document is 12pt, 1em is equal to 12pt. Ems are scalable in nature, so 2em would equal 24pt, .5em would equal 6pt, etc. Ems are becoming increasingly popular in web documents due to scalability and their mobile-device-friendly nature.
2. Pixels (px): Pixels are fixed-size units that are used in screen media (i.e. to be read on the computer screen). One pixel is equal to one dot on the computer screen (the smallest division of your screen’s resolution). Many web designers use pixel units in web documents in order to produce a pixel-perfect representation of their site as it is rendered in the browser. One problem with the pixel unit is that it does not scale upward for visually-impaired readers or downward to fit mobile devices.
3. Points (pt): Points are traditionally used in print media (anything that is to be printed on paper, etc.). One point is equal to 1/72 of an inch. Points are much like pixels, in that they are fixed-size units and cannot scale in size.
4. Percent (%): The percent unit is much like the “em” unit, save for a few fundamental differences. First and foremost, the current font-size is equal to 100% (i.e. 12pt = 100%). While using the percent unit, your text remains fully scalable …

R0bb0b 344 Posting Shark

or die(mysql_error()) should not be on line 16 but 17

R0bb0b 344 Posting Shark

my first guess would be a sql error and I am suspicious of your column name "Company/Name". I have never seen this done and am guessing that you may have to escape that "/" so it would be "Company\/Name".

I would try to change the column name in the future to an _ or - to prevent future issues.


[EDIT]
you also have some spaces in your column names and would have to surround them with ``.

$ud_query = "UPDATE `$table` SET `Company\/Name` = '$ud_name', Code = '$ud_code', `Account Info` = '$ud_acct', `Phone Number` = '$ud_phone', Username = '$ud_user', Password = '$ud_pass', Website = '$ud_web' WHERE id = '$ud_id'" or die(mysql_error());

you could also try this but my bet is on the first:

$ud_query = "UPDATE `$table` SET `Company//Name` = '$ud_name', Code = '$ud_code', `Account Info` = '$ud_acct', `Phone Number` = '$ud_phone', Username = '$ud_user', Password = '$ud_pass', Website = '$ud_web' WHERE id = '$ud_id'" or die(mysql_error());
R0bb0b 344 Posting Shark

the semi colon shouldn't make a difference since it is the last property being specified. Make sure though that you are specifying the unit of measure for font-size: for example 12px or 12em where px and em are the unit of measure and won't do anything if you don't include it.

R0bb0b 344 Posting Shark

I have tried this and it seems to work as expected, I think. Can you please explain what it is you are trying to do and what the desired and undesired results are that you are getting. This is probably a simple logical error.

R0bb0b 344 Posting Shark

Also, you should never store plain text passwords in your database. I would do some research in the php function md5 to create an md5 hash of the passwords and then you can compare the md5 hash version of the password submitted by the user to the md5 hash version stored in the database. You can also use something like aes_encrypt and aes_decrypt which is a very easy way of encrypting and decrypting data with mysql.

That is if you are creating a website and not some school project. You don't want to be in a situation where a hacker gets into your server and starts downloading email addresses and passwords, that would be bad.

R0bb0b 344 Posting Shark

This is how I usually do it:

<?php
$querylog = "TRANSACTION STARTED<br /><br />";
$commit = "commit";
mysql_query("begin", $dbconn);

$query = "insert into ...";
if(!mysql_query($query, $dbconn))
{
	$commit = "rollback";
	$querylog .= "error in query: " . $query . " : " . mysql_error($dbconn) . "<br /><br />";
}

$query = "insert into ...";
if(!mysql_query($query, $dbconn))
{
	$commit = "rollback";
	$querylog .= "error in query: " . $query . " : " . mysql_error($dbconn) . "<br /><br />";
}

$query = "insert into ...";
if(!mysql_query($query, $dbconn))
{
	$commit = "rollback";
	$querylog .= "error in query: " . $query . " : " . mysql_error($dbconn) . "<br /><br />";
}

if($commit == "rollback")
{
	$querylog .= "ERROR IN TRANSACTION<br /><br />transaction rolled back<br /><br />";
	//echo $querylog;
}

mysql_query($commit);
?>
R0bb0b 344 Posting Shark

You didn't close the if statement at line 7, this should work:

<?php
include 'config.php';
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

//check if submit button was pressed
if($_GET['categoryname'])
{
	//to protect from mysql injections
	 $remove=mysql_real_escape_string($_GET['categoryname']); 
	 $remove = stripslashes($remove);
	
	$sql = "DELETE FROM categories WHERE `category` = $remove ";
	
	
	//declare in the sql variable   
	$result = mysql_query($sql);  //order executes   
	if($result)
	{
		echo("<br>Category deleted");
	}
	else
	{
		echo("Failed to Delete category");
	}
}
?>
R0bb0b 344 Posting Shark

still getting the same error on the same line.

Could you post your updated code? I'll test it.

R0bb0b 344 Posting Shark

Okay I've changed the brackets to the following and
now I'm getting the following error.
"parse error: syntax error, unexpected $end in removecategory.php on line 24

18. If($result){
19. echo("<br>Category Deleted");
20. }
21. else{
22. echo("Failed to delete category");
23. }
24. ?>

did you capitalize "If($result)" in your code? I'm pretty sure that won't work. If so, change it to "if($result)"

$_get is suppose to be $_GET

That's all that I see off the top of my head, make those changes and run it again.

R0bb0b 344 Posting Shark

I get an syntax error when it hits the "else' statement.

You have an odd number of brackets here

if($result){ 
{  
echo("<br>Category deleted");
}
else{
echo("Failed to Delete category");
}
R0bb0b 344 Posting Shark

So what do you know is happening? Meaning, at what points in your processing script(code that the form is submitted too) does focus reach? Does this make sense?

I'm not asking for a diagnosis of your problem, I'm trying to see if you have done any debugging yourself yet. Does your script process past your config file? Is this "if($_get){" firing at all. Does the script even get to this point "$result = mysql_query($sql);".

At some point you are going to want to insert "echo $sql . '<br />';" so you can actually look at what is being sent into the database.

You should strategically place echo statements throughout your script, temporarily, so you know these things to help you to isolate the actual issue that is going on.

Does this make sense?

R0bb0b 344 Posting Shark

i have a switch going on and when it clicked on "IT" it needs to send the information to two email address. I got it so it sends to one but i cant get it to send to two. I am new to php but in c++ I think you did one of these numbers...> to add on same line. Does this help?

Are you trying to concatenate the strings?
$to_email = "erich.krauz@rgl-e.com" . ", krauz2@hotmail.com";

this would be
$to_email = "erich.krauz@rgl-e.com, krauz2@hotmail.com";

R0bb0b 344 Posting Shark

I have tried a few different ways to get two email address to send on a case statement. How do I add to commands on same line? I am just a little off track. Thanks for your help.

case 'it':
$to_email = "erich.krauz@rgl-e.com"; $to_email = "krauz2@hotmail.com";

break;

Could you expand on this. This is two commands on the same line but because you are using the same variable, the first command is pointless. What are you trying to do?

R0bb0b 344 Posting Shark

Ok thanks guys, yours worked xan, RObbobs' didn't when I changed the bracket it gave me another whole page of errors. now i'm getting this: Parse error: syntax error, unexpected $end in /home/a5957980/public_html/includes/functions.php on line 247

You would think that people who make & sell this scripts would check to see that they work correctly!

Either way, this is still not going to work because you are closing your first function with an open bracket

<?
$conf = mysql_fetch_array(mysql_query("SELECT * FROM config WHERE id = 1"));
function check_credits($email,$credits)
{
	$user = get_user_info_email($email);
	if ($credits < $user[credits] OR $credits == $user[credits])
	{
		return true;
	}
	else
	{
		return false;
}
{
function check_url_user ($email,$url_id)
{
	$user = get_user_info_email($email);
	$query = mysql_query("SELECT * FROM urls WHERE id = '$url_id' AND user_id = '$user[id]'");
	$numrows = mysql_num_rows($query);
	return $numrows;
}
?>

line 14 needs to be } not {. By the time you get to the bottom of all of your errors you will still have an "expecting }" or an "expecting {" error.

R0bb0b 344 Posting Shark

Here are your first 34 lines

<?
$conf = mysql_fetch_array(mysql_query("SELECT * FROM config WHERE id = 1"));
function check_credits($email,$credits)
{
	$user = get_user_info_email($email);
	if ($credits < $user[credits] OR $credits == $user[credits])
	{
		return true;
	}
	else
	{
		return false;
	}
{
function check_url_user ($email,$url_id)
{
	$user = get_user_info_email($email);
	$query = mysql_query("SELECT * FROM urls WHERE id = '$url_id' AND user_id = '$user[id]'");
	$numrows = mysql_num_rows($query);
	return $numrows;
}
function check_banner_user($email,$banner_id)
{
	$user = get_user_info_email($email);
	$query = mysql_query("SELECT * FROM banners WHERE id = '$banner_id' AND user_id = '$user[id]'");
	$numrows = mysql_num_rows($query);
	return $numrows;
}
function logout()
{
	setcookie("EMAIL","");
	setcookie("PASSWORD","");
	$message = "You have successfully logged out";
}
?>

line 14 is suppose to be a } not {

R0bb0b 344 Posting Shark

Great that did it! TY any ideas on the other error:

<?
$conf = mysql_fetch_array(mysql_query("SELECT * FROM config WHERE id = 1"));
function get_num_websites()
{
$query = mysql_query("SELECT * FROM urls");
$numrows = mysql_num_rows($query);
return $numrows;
}
function get_num_banners()
{
$query = mysql_query("SELECT * FROM banners");
$numrows = mysql_num_rows($query);
return $numrows;
}
function get_num_users()
{
$query = mysql_query("SELECT * FROM users");
$numrows = mysql_num_rows($query); <<<<<<<<<<<< line 18
return $numrows;

}

This says that it is expecting one of these "{". Is this the entire code from this file?

R0bb0b 344 Posting Shark

please get me some information...
please.....

Do you have something put together online so that we can look at it? I'm just not exactly sure if I know exactly what you are talking about.

R0bb0b 344 Posting Shark

Yes I see what you mean. So I would need to store every vote in a database.

I was thinking something similar to this might work:

$pid = $_GET['pid'];
$newrating = $_GET['rating'];

include('../../php/database/connect.php');

$query  = "SELECT * FROM products WHERE pid = '".$pid."'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
explode(',',$votes);
$votesnumber = count($votes);

but I do not know where to go from there. Also there is a problem with the character limit in a MySQL database and eventually I would run out of voting space?

Do you really think the votes will get that high? Your talking about exceeding the allowed integer limit? If you use a mediumint, that's 8388607/5 and over 1.5 million votes. Mediumint only takes 3 bytes. That would be in comparison to a varchar with 2 characters in it.

R0bb0b 344 Posting Shark

OK, so what you are doing in your code is taking the current rating, adding the new rating to it, averaging that by dividing that by all votes. This will not work because you are not preserving the votes. For instance, if someone votes 5, what you do is take the 5 and add the current rating to it, but since lets say this is the first vote, the current rating is 0. So your current rating is 5 and the number of votes is 1 so you take 5/1 and that makes the current rating 5. Now take the second vote and follow the same process. Someone else comes around and votes 3. What you do is take the current rating add three to it and divide it by the number of votes so 8/2 makes the current rating 4, BUT rather than preserving that vote as 3 and using it in the next calculation when the 3rd person votes you store the average in rank. Is this making sense yet.

You can store rank at the time the vote was made but you HAVE to store the vote and calculate (vote+newvote)/(numvotes+1) what you are doing is (currentrank+newvote)/(numvotes+1). You must add up all the votes and divide by the number of votes not add up all the rankings at the time the votes were made + the new vote and divide by the number of votes.

Does this help?

R0bb0b 344 Posting Shark

Your calculations are not correct if you are looking for an average, I have just gotten busy and will have to get back to you on the error shortly.

R0bb0b 344 Posting Shark

I see it now, wouldn't work if firefox, switched to IE and I can see where the images are suppose to be. Only the rollovers work. Attached is what I see. Could have something to do with the network I am behind as well, maybe.

R0bb0b 344 Posting Shark

I see a button to add to basket but I don't see a button to vote

R0bb0b 344 Posting Shark
mysql_query('UPDATE `web163-zavvex`.`products` SET `rating` = "'.$newnewrating.'" WHERE `products`.`pid` = "'.$pid.'" LIMIT 1');
mysql_query('UPDATE `web163-zavvex`.`products` SET `numberofrates` = "'.$numberofrates.'" WHERE `products`.`pid` = "'.$pid.'" LIMIT 1');

Why do you have to have "limit 1" on your update queries, is "pid" not your primary key. If not, maybe you are having issues with duplicate rows? This could produce unpredictable results.

R0bb0b 344 Posting Shark

Hi all

Just a quick question, I have avoided the ternary operator type If statement a lot in my code, because personally I find it easier to read a statement like this:

if (empty($_POST['action'])) {
    $action = 'default';
} else {
    $action = $_POST['action'];
}

Rather than:

$action = (empty($_POST['action'])) ? 'default' : $_POST['action'];

My question is: Is there any advantage to using the Ternary operator over a standard IF statement other than obviously saving a few characters...

Not really, just when you start doing it, it becomes habit forming. Its great for auto filling form fields like drop down lists and checkboxes, so in that case yes, it makes it much easier to read.