darkagn 315 Veteran Poster Featured Poster

The code that ivatanako has given you is probably as simple as you can get. It will allow you to connect to your database and run a query. You can extend it if you need, but I can't see how it could be simplified further as you need those steps to be able to do anything in mysql and php.

darkagn 315 Veteran Poster Featured Poster

So if you have less than two words, there is no space. You need to add an "else" for your first if-statement, like so:

function text_limit($str,$limit=10)
{
  if(stripos($str," ");
  {
      $ex_str=explode(" ",$str);
      if(count($ex_str)>$limit)
      {
        for($i=0;$i<$limit;$i++)
        {
           $str_s.=$ex_str[$i]." ";
        }
        return $str_s;
      }
      else
      {
         return $str;
      }
   }
   else
   {
        return $str;
   }
}

Also, there are probably more efficient ways of achieving this than exploding and rebuilding the original string. But this quick fix should work for you.

darkagn 315 Veteran Poster Featured Poster

This post is just to see the function with formatting, I will try to help you shortly.

function text_limit($str,$limit=10)
{
  if(stripos($str," "))
  {
    $ex_str=explode(" ",$str);
    if(count($ex_str)>$limit)
    {
      for($i=0;$i<$limit;$i++)
      {
        $str_s.=$ex_str[$i]." ";
      }
      return $str_s;
    }
    else
    {
      return $str;
    }
  }
}
darkagn 315 Veteran Poster Featured Poster

Yes that is exactly what they are saying, although it would not be a txt file but a php file. Many sites also add a .inc extension to include files, for example:

include("home/includes/constants.php.inc");
darkagn 315 Veteran Poster Featured Poster

You need to iterate through each of the table rows like so:

$sql = "SELECT * FROM ddcart_products";
$result = mysql_query($sql);
$totalweight = 0;
while($data = mysql_fetch_assoc($result))
{
  echo '<br />';
  echo $data['name'];
  echo '<br />';
  echo 'Weight: '.$data['weight'];
  echo '<br />';
  echo 'Qty: '.$value;
  echo '<br />';
  $weight = $value * $data['weight'];
  echo 'Weight: '.$weight;
  echo '<br />';
  $totalweight += $weight;
}
echo "Total Weight = $totalweight<br />";
darkagn 315 Veteran Poster Featured Poster

I haven't used phpmyadmin but I believe it has an SQL Query editor somewhere that you can enter your create procedure query into. That really should be all there is to it...

darkagn 315 Veteran Poster Featured Poster

I'm sorry jay_412 but I don't understand what you are asking. You simply need to run the mysql create procedure query. This can be done in php, or on the command line in Windows, or the shell in Linux, or in a MySQL editor such as SQLyog.

darkagn 315 Veteran Poster Featured Poster
darkagn 315 Veteran Poster Featured Poster

You don't need to "put" your stored procedure somewhere, you create one by executing a CREATE PROCEDURE statement. As cwarn23 mentioned, you will need a database with tables etc for your procedure to be able to do anything.

darkagn 315 Veteran Poster Featured Poster

Certainly it is important to liase with the end user in any project. If you are managing a database for accountants, then yes you will need to understand what they will use the database for and what information they expect to be able to recall.

For your second question, might be best to ask a finance expert what they would suggest, but I am sure there are many good books that can bring you up to speed with finance terminology and practices. GoogleBooks or Amazon might be a good place to start browsing.

darkagn 315 Veteran Poster Featured Poster

Also, make sure that you never send unencrypted passwords via GET as they will be visible in the URL. There are also hacking tools which allow the retrieval of POST data, so watch out for that too.

darkagn 315 Veteran Poster Featured Poster

They are not rigged. Do research before you answer some question
that you are not 100% sure.

In Australia the law states that gaming machines must have a return to player ratio of at least 86%. That is, over the long term, every $1 spent wins 86 cents (or loses 14 cents) per spin on average. In some sense this means that they are not truly random. I'm not saying they are rigged, but the mathematics behind them is not as simple as the example previously given.

However for exercise purposes the equations given can be used to determine a particular result for a single spin in a truly random set of results.

darkagn 315 Veteran Poster Featured Poster

In addition to what Ez has said, I would change your forever loop (that is your for(;;) ) to while(cash > 0) , that way when the player runs out of cash the game is over.

darkagn 315 Veteran Poster Featured Poster

Hi andym67 and welcome to DaniWeb :)

A better approach is this:

if(isset($_SESSION["namevalue"]))
   $val = $_SESSION["namevalue"];
else
   $val = "";
// maybe do some validation on $val here
echo "<input name='fname' type='text' class='textfield' id='fname' value='$val' />";

or:

<?php
if(isset($_SESSION["namevalue"]))
   $val = $_SESSION["namevalue"];
else
   $val = "";
// maybe do some validation on $val here
?>
<input name="fname" type="text" class="textfield" id="fname" value="<?php echo $val; ?>" />;
darkagn 315 Veteran Poster Featured Poster

Ah ok, so are all of your fields of type VARCHAR? Might be worthwhile changing to NUMERICs if you are going to be joining tables a bit, that is if that doesn't mess everything else up!

darkagn 315 Veteran Poster Featured Poster

I believe that IS the test. Just go through each of those 20 items and score yourself a 0,1 or 2 as the dude has said.

BTW I scored a 4 which I don't believe makes me saintly, just not psychopathic.

darkagn 315 Veteran Poster Featured Poster

Are you sure that your $_SESSION is set correctly? Try echo'ing your sql statement before you send it to mysql_query and see...

darkagn 315 Veteran Poster Featured Poster

I think these lines

<option value="0"   <?php  ($installtype == "0") ? "selected" : ""; ?> >Install with CPanel Info (can create  MySQL  DB  automatically)</option>

should be

<option value="0"   selected=<?php  ($installtype == "0") ? "selected" : ""; ?> >Install with CPanel Info (can create  MySQL  DB  automatically)</option>

Also, you should always use <?php in favour of the shorthand tags. Some servers do not support the shorthand tags, so for maximum compatibility use the longer version (it's only 3 more characters and the benefit is certainly worth it).

darkagn 315 Veteran Poster Featured Poster

Back when I worked for the Australian Defence Department I was writing code that simulated warships communicating with each other. During testing I had 4 pc's talking to each other via UDP and TCP communication. The hardest part about it all was remembering which ship was being simulated by which PC!

darkagn 315 Veteran Poster Featured Poster

So is $title the title of a single RSS feed item? If so, you can do something like:

$count = 0;
foreach($rssFeedItems as $title)
{
   if(empty($title))
      echo ++$count; // a prepend increment will add one to $count before it is used
   else
      echo $title;
}
lonestar23 commented: Great Coder! +2
darkagn 315 Veteran Poster Featured Poster

I must admit that javascript is not my strong suit, but I will try to help. The line

tbl2 = tbl2 + GenerateRow()

What happens in javascript if you call a function without the parameter in the method signature? Also you appear to be missing several ;'s to end your statements, not sure what effect this might have?

darkagn 315 Veteran Poster Featured Poster

Hi gouthamvel and welcome to DaniWeb :)

I think we may need a bit more information to help you on this one. Can you please post the code for the select tag that this option tag is a part of? What do you mean by the script won't work? Does the page load? Is it just not displaying the options in the select? Are there any error messages? Is it the function that doesn't work as you would like and if so does anything happen when you call it?

darkagn 315 Veteran Poster Featured Poster

The key to solving this problem is how the form is submitted when the user selects from the first drop down. When the form is submitted, their selection is placed in the superglobal array $_POST with the array key equal to the name parameter of your select tag. Your form action tells the page to go to the script new_job_form.php when the form is submitted which is hopefully the same script. Now what you need to do is retrieve the results of the form's submit like so:

if(isset($_POST['select_client']))
   $clientId = intval($_POST['select_client']);
else
   $clientId = -1; // or some other value which indicates none selected
// you should validate $clientId and make sure that it is not invalid here

Ok, now that we have our client id, how to use it? First we need to set the fact that the client is selected in the first select, so change your first select tag to look like this:

<select name="select_client" onchange="this.form.submit()" value="<?php echo $clientId; ?>" >

Now in your SQL statement for selecting the options for the second select tag, change it to the following:

$query2= "SELECT * FROM client_contact, clients WHERE client_contact.ClientID=clients.clientID AND clients.clientID = $clientId";

Hope this helps, although I must admit I haven't tested the code I have given you so you may need to fiddle a little bit to get it to work.

darkagn 315 Veteran Poster Featured Poster

I suppose your visibility function will look something like this then:

function getVisibility($active)
{
  if($active == true)
      return 1;
  else
      return 2;
}

However, it might be better to simply assign inactive to 0 as this maps directly to false, that way active = true and inactive = false.

darkagn 315 Veteran Poster Featured Poster

Days are simple, take a look at the date() function in the documentation at www.php.net for more info.

What do you mean by visibility? Of the days?

darkagn 315 Veteran Poster Featured Poster

Basically you need to call mysql_connect with your connection info parameters in a line before the line I have indicated. Or it could be being called in the script /Connections/classifieds.php, in which case the line that reads

<?php ('/Connections/classifieds.php'); ?>

should read

<?php require_once('/Connections/classifieds.php'); ?>

There are other options other than require_once, but I think this is the most appropriate solution. Again, this is only if mysql_connect is called in this script, so check the code in that file.

darkagn 315 Veteran Poster Featured Poster

>If you specify an invalid language, it defaults to using the one from the
>current forum. csharp is now invalid in favor of C#. For c++, you can do
>C++ or cpp.

code=php is not working in the PHP forum.

EDIT: Just went back to get a screenshot to post, now it is working as before :$

darkagn 315 Veteran Poster Featured Poster

Hi hmkk and welcome to DaniWeb :)

mysql_select_db($sumdueu_urworld, $sumdueu_admin);

Your problem is most likely that the variable $sumdueu_admin has not been created correctly. This must be done with a call to mysql_connect() before the call to mysql_select_db() is made. This can occur in a previous script in your website, but I would say that it has not yet occurred when this line is reached.

For more information, visit the documentation at www.php.net or google mysql_connect for PHP.

darkagn 315 Veteran Poster Featured Poster

Hi Mujahid158 and welcome to DaniWeb

The mysql_query function returns a result set resource for select queries. You can't access it in the way that you are attempting, you need to specify the index of the resource. Like so:

echo $mem["username"];

For further information on the function, please see the documentation at www.php.net

darkagn 315 Veteran Poster Featured Poster

There are a few ways you can do this, but the simplest is probably to pass the variable via GET. To do this add the following line of code after you set $errorpas:

header("Location: User.php?errorpas=$errorpas");

Then at the top of your User.php script add the following lines:

if(isset($_GET["errorpas"]))
   $errorpas = $_GET["errorpas"];
else
   $errorpas = "";

// may need to perform some validation of what has been passed before you use it

If you google $_GET for php, you will get a better understanding of how to pass variables between php pages.

EDIT: I have assumed that you are trying to display the error message on the page User.php. If you are trying to display on Modify.php, change where I have written User.php to Modify.php.

darkagn 315 Veteran Poster Featured Poster

Is there another variable with the name $results in your code or in an included file? Also I think you might want to use >= and <= rather than > and < in your comparisons.

darkagn 315 Veteran Poster Featured Poster

Not sure if this is your problem but have you restarted your webserver after installing the GD extension?

darkagn 315 Veteran Poster Featured Poster

There are a few different types of SQL, but http://www.w3schools.com/sql/default.asp is a good site for general SQL knowledge. http://www.sql.org/sql-database/sql-tutorial/ is a good beginner's tutorial but it is a little slow-paced for my liking - if you have programming experience you may feel the same. SQL is not too difficult when you get started, I have mostly learned just from trial and error.

Not sure what you mean by data controls? If you are talking Silverlight am I correct in thinking you mean C# user controls to access a database?

darkagn 315 Veteran Poster Featured Poster

Go to http://www.php.net/docs/ Start reading and start coding.

I agree. Also there are tons of tutorials and code samples available on the web. Google is your friend.

darkagn 315 Veteran Poster Featured Poster

I would have a single table, called user_pref, which would have the columns user_id, product_type_id, both of which would form the primary key for the table. If the user selects pets as a preferred option, add their user id and the pets category's id to the table. If the user then also selects the gardening category, add that to the table to.

When you display the items, check the table for preferences and if there is at least one row for their user id only display items in the categories listed, otherwise display items from all categories.

Hope this helps :)
darkagn

darkagn 315 Veteran Poster Featured Poster

If you mean a text box to type your title into, then you need to use an input tag of type text for a one-line box or a textarea tag for a multi-line textbox. If you are after a select box that you can type in, that will require some javascript I think. Google should provide plenty of examples.

darkagn 315 Veteran Poster Featured Poster

Hi iamjmurphy and welcome to DaniWeb :)

Can you please provide more information of your table structures and which fields you are trying to compare? It seems like it should be a fairly simple task, but I'm unsure exactly what you are trying to achieve.

Cheers
darkagn

darkagn 315 Veteran Poster Featured Poster

Well, technically yes. A better solution would probably be:

if ($_SERVER['REMOTE_ADDR'] == '127.0.0.1') 
{
// request comes from this server
}

but even this would probably not be too safe. What are you trying to achieve by knowing the request was from the server?

darkagn 315 Veteran Poster Featured Poster

What do you mean by "Game Developer Software"? IDE, Modelling Software, Game Engine, Compiler, or something else perhaps? It will most likely be a matter of opinion anyway, can you narrow down your criteria of what you are trying to achieve?

EDIT: Oh, are you also CMSHelper? Perhaps this is just a way of spamming your signature?

darkagn 315 Veteran Poster Featured Poster
$desc->lastname = "Penner";

I believe your problem lies with this line of code. If you echo $desc to screen I think you will find that it relates to the lastname tag, not the user tag, so it is inserting a child of the lastname tag which is not what you want. If you change that line to this:

$desc = "Penner";

I think that will be closer to what you are after.

darkagn 315 Veteran Poster Featured Poster
$send="INSERT INTO mailbox SET
   member_id='$memid',
   user_name='$$_SESSION[user_name]',
   user_id='$_SESSION[user_id]',
   message='$message',
   inbox='NEW',
   subject='$subject',
   date='$dsub' " ;
$save_result=mysql_query($save);

What is $save? I think you are trying to run the query $send?

darkagn 315 Veteran Poster Featured Poster

Read up on arctan. It might give you a few ideas...

darkagn 315 Veteran Poster Featured Poster

The GridBagLayout is possibly what you will need. However, it is possibly the most advanced of Java's standard layouts. It gives you full control over margins (Insets) which gives great control over alignment issues. A google search should provide plenty of examples of the use of this layout.

darkagn 315 Veteran Poster Featured Poster

Basically the way that it works is everything after the ? is a set of key-value pairs. So, if you need to find $_REQUEST["msg"] you need the URL to read http://xxxxx.php?msg=zzz

Hope this helps,
darkagn

darkagn 315 Veteran Poster Featured Poster

The FIND_IN_SET function is used to search a list of strings for a specific string. I don't think you need to do this. Your query should look something like this I think:

$tag = $_GET[tag];
// NEED TO PERFORM SOME DATA CHECKS HERE...
$search = mysql_query("SELECT * FROM threads WHERE tag = '$tag'");
darkagn 315 Veteran Poster Featured Poster

That's why I was thinking it was a hack and not Dani herself.

darkagn 315 Veteran Poster Featured Poster

Hi cscgal (and other site administrators),

I recently received a PM from cscgal asking me to fill in an online survey. I was willing to do so, but just before I pressed the Submit button, I wondered if maybe her account had been hacked by a spammer. Does anyone know if this request from cscgal is genuine or not?

Cheers,
darkagn

darkagn 315 Veteran Poster Featured Poster

Hi Patrick,

Unfortunately it is not as simple as that. Different languages are better at different tasks. Most are designed to perform specific tasks at first and grow from there. Really what you need to do is work out what you are trying to achieve and then select the best tools for the job.

Hope this helps,
darkagn

darkagn 315 Veteran Poster Featured Poster

Yes, with care. Always perform checks on session data to maintain security and integrity. For example:

$goal = $_SESSION["goal"];
if (strlen( $goal ) < 1)
   $goal = "Not set";

Just a simple example, but you get the idea...

darkagn 315 Veteran Poster Featured Poster
if(51 < $bal && $bal < 75)

This statement reads "if $bal is GREATER THAN 51 and LESS THAN 75". If you have $bal EQUAL to 51 it is not GREATER THAN 51. (Sorry for the shouting, but it is necessary to emphasise my point).

What you need is this:

if( $bal >= 51 && $bal < 75)

Similar for the rest...