How are you connecting? Wireless or Wired?
Have you tried contacting your ISP directly? If you're using wireless, why not try using wired (ethernet) and see if you disconnect.
Hope this helps a bit :)!
How are you connecting? Wireless or Wired?
Have you tried contacting your ISP directly? If you're using wireless, why not try using wired (ethernet) and see if you disconnect.
Hope this helps a bit :)!
I don't understand what you're trying to say? Erm, screenshot / example?
I'm guessing you mean, you have 4 places for advertisements and you want to display the advertisement if there is a record, if there isn't then it leaves it blank? So, if there is 2 advertisements, then, there would it would display "place your advertisement here" etc.. :)
It's called Google, been around for a very long time and has a really nice UI you can use ;)
This code:
if($SM_pro){
Basically is saying if SM_pro == true, however, DM_pro is an array, so, therefore it won't return true/false. You could try:
if($SM_pro <= 0) {
Alternatively, you could use the mysqi_num_rows() function.. http://www.nusphere.com/kb/phpmanual/function.mysqli-num-rows.htm
Hope this helps :)
It does not know what 'slno' is.. store inside a session :)
Hey,
"boolean" is not a data type, look at the correct definition/declartion
Also, are you defining the function prototypes before main (since you're using them after main) because if not, the program won't know where to call the fucntions.
Hope this helps :)
Hello,
So basically, here is my code:
vector<iniMatrix> Audio::subBlocks(vector<float>& theData, int N, int M)
{
int n = theData.size();
int maxblockstart = n - N;
int lastblockstart = maxblockstart - (maxblockstart % M);
int numblocks = (lastblockstart)/M + 1;
vector<float> subBlock;
vector<iniMatrix> block(numblocks);
for(int i=0; (i < numblocks); i++)
{
for(int j=0; (j < N); j++)
{
subBlock.push_back(theData[i*M+j]);
block[i].push_back(subBlock[i]);
}
}
cout << block[0][0];
return block;
}
I'm converting the code from Matlab and the results don't match.. For example:
If I output block[1][2] it will give me 203 however, block[1][2] in matlab is 200..
Hey, I might be having a blonde moment but here goes..
I'm trying to split a massive 1D vector into blocks at different places (If that makes sense), it should basically go like this:
0
201
401
601
801
..
..
..,
57201
2
202
402
602
..
..
..
..
3
302
402
602
But, for some reason, it prints out as:
0
1
2
3
..
..
..
Here's a tiny bit of sample code:
for(unsigned i=0; (i < numblocks); i++)
{
for(unsigned j=0; (j < N); i++)
{
cout << (i*200+j) << endl;
}
}
In my head (and on paper) it should go.. 0, 201, 202.. But it doesn't.. Any ideas? Thanks :)
Hey,
Numbers_roman::tonumeral($year);
This looks like a namespace, however, I might be wrong. See: http://php.net/manual/en/language.namespaces.php
and
require_once("numbers/roman.php")
This this includes the file, but, instead of the "include" function which will only execute an error, this function will die if there is an error. By using the require_once, it will check to see if the file has already been included and if it has, not include it again.
Hope this helps :)
@Yorkiebar14 No problem - Please mark this thread as solved and give rep to those who helped you (By clicking the arrows etc..).
Are you creating a Forum? If so, it looks like your logic is a bit out, you should re-think this.
Instead of:
if($v)
{
}
Try using:
if(isset($v))
{
}
I don't know which part the final else statement relates to. mhmh!
@Yorkiebar14 You can search on google for tutorials search "preg_replace" etc..
And no, not really, depending on how many characters you want them to enter. It depends on what you're showing.. If there's going to be quite a lot of text you can use data types like mediumtext, longtext etc.. But in theory, you would display it as you would their username.. E.g.
<?php
// mysql connection
$id = $_GET['id']; // validate this.
$q = "SELECT * FROM page WHERE page_id='$id'";
$r = mysql_query($e);
while($row = mysql_fetch_array($r))
{
//
}
@eharrell - Everyone had to learn somewhere (Even us) :) and in respect, we're all still learning hence why some of us are on here!
You should start writing out the steps on paper, asking how you would do it and try it.. The worst that can happen is a few compiler errors!
Good luck and keep posting on the forums - it's a great way to learn :)!
@Yorkiebar14
Right, so if we're talking about pages, then, it would just be an ID.. E.g.
www.yoursite.com/page.php?id=1 -> will get the information from the '1' ID.
how can they store HTML in the database? Or at least give their text colours etc?
You can store HTML and then output it, however, this isn't really an advised method. INSTEAD, use bbcodes / formatting codes and disable HTML completely and just parse it using PHP. Here's an example:
Input:
[b]Hello my name is Phorce[/b]
Output:
Hello my name is Phorce
You can do this for pretty much anything, it can get really technical and advanced depending on what formatting you want to do. For example [p][/p] and you could even have a positioning system, just think of it like a "grid".
An alternative route (and I have used this method before) is to implement a drag/drop for "divs" in which the user can drag the elements on the page, and when they drop the element it updates itself.
Hope this helps :)!
Hey, I would do this using a SWITCH statement, over an if statement - If I'm honest.
I haven't completeled this, but, look at this logic.. It might help you. Re-write the code for your own use, don't just use it!
#include <iostream>
using namespace std;
int hoursToStudy(char grade)
{
switch(grade)
{
case 'A':
return 5;
break;
case 'B':
break;
case 'C':
break;
case 'D':
break;
case 'F':
break;
default:
cout << "Cannot define the grade";
break;
}
}
int main(int argc, char *argv[]) {
cout << hoursToStudy('A'); // prints 5
}
Logic is pretty simple :)!
@LastMitch - Oh, I see :P This can be done using jQuery / Ajax! The preview etc.. And then just parse the BBcodes in as you would normally in PHP.
@griseindria - Just select it off SESSIONS then..?
I.e.
<?php
if(!isset($_SESSION['user_session']))
exit("You do not have permission to access this page, sorry");
$query = "SELECT * FROM profile WHERE user_id='{$_SESSION['user_id']}'";
$res = mysql_query($query);
if(!mysql_affected_rows() == 1)
exit("Couldn't find the details");
while($row = mysql_fetch_array($res))
{
// only display the users details
}
?>
@LastMitch, I'm confused to what you mean by "Text Editor" :P
Ok, back to the OP.. So, you want a profiling system for your users. It's surprisingly simple, I'll guide you through the concepts, and, you can code it or find tutorials out there..
So first off, you need a user system (This includes: Sign-in, sign-up etc.) and you should take full advantage of SESSIONS, as, these will come into great use later on.
To answer your profile section, you would have to use $_GET to retrive this from a database, so it will look a bit like this:
<?php
$foo = $_GET['user_id'];
$query = "SELECT * FROM Accounts WHERE user_id='$foo'";
$res = mysql_query($query);
// everything else
Then you would provide links like:
www.yoursite.com/profile.php?id=1
And this should hopefully show the first person in the database :P!
THIS method can work for forums etc. But, will act a bit differently. I built a forum a few years ago and once you have the concept, it is a lot easier, but, it's one of them things you need to sit down and draw out the logic rather than asking on forums ;)!
and then apply inheritance in your classes.
No to both; you've already been told which classes to write, and there is no inheritance relationship involved:
Shouldn't some relationship be here though? Ok, so inheritence can have a "Is a"/"Can Be" relationship so obviously "Customer" {is a} "Item" wouldn't work, however, association could be used, surly? Customer {can have} "Item" relationship would, IMO anyway.. I might be wrong!
Shouldn't this:
<?php
while($row = mysql_fetch_array($result))
{
echo "<a href='members_profile.php?id=<?php echo $row[0];?>' >" .$row['username'] . ', ';
}
?>
Be this:
<?php
while($row = mysql_fetch_array($result))
{
echo '<a href="members_profile.php?id=' .$row[0]. '">' .$row['username']. '</a>';
}
?>
Also, with this code:
<?php
session_start();
Connected to database here
$sql = "select * from users where username='{$_GET['uid']}'";
?>
Be very careful about just passing in $_GET params through queries, it's really bad. Store it in a variable and perform validation on it.
Hope this helps :)!
Could you just var_dump($server_id) and $username, make sure they are not returning NULL. Thanks :)!
Hey, why not try mysql_affected_rows()?
E.g.
//This session value is created at login
$username = $_SESSION['valid'];
//This is written to the URL
$server_id = $_GET['server'];
//See if a server exists with this ID and Username
$query_server = "SELECT id FROM servers WHERE id='".$server_id."' AND `administrator`='".$username."'";
$result=mysql_query($query_server);
if(mysql_affected_rows() == 1)
{
// redirect for Yes
}else{
// redirect for no, take users back to their account
}
Some people may not agree with the mysql_affected_rows but I've always used it, and, would for this. Also, $server_id, I would run validations (is_numeric etc..) before I passed it into a query.
Hope this helps :)
Hey I just tried your script, it didn't work for me so I changed it and this works:
<?php
$filename = 'file.php';
if(file_exists($filename))
{
header( 'Location: welcome.php' ) ;
}
else
{
echo "NO FILE";
}
?>
@EmilyJohnson that could not possibly work.
Try avoiding outputting variables in functions, but, return them:
<?php
function country($country)
{
return $country;
}
echo "i am going to " . country("USA") . "<br />";
?>
i am going to USA
wow @simplypixie for down voting.. I'll code up a style sheet next time, just to show the user an example. :S
Hey,
You need to firstly look into arrays, and, then how to pass (array pointers) into functions, once you've found these things out you can then sort the array (bubble sort e.g.) and find the lowest value. Not allowed to provide a solution to this probem!
IF this thread has been solved, please mark is as solved and give rep to those who helped you :)!
Hey,
You're not breaking your cases, after each case you need to have a break otherwise it may just jump to the next case etc. Also, you need to have/suggested that you always have a default case. Here's an example:
int main()
{
int number;
switch(number)
{
case 0:
// case 0
break;
case 1:
// case 1
break;
default:
cout << "This is the default case";
break;
}
}
As another note, in the example you provided, are switch statements really useful? You only have two outcomes, which, can be handled with an IF statement. Usually, (personally) I use switch statements when handling menues, or if I have multiple options.
P.S. The output of "cPass" will only be "sucsess" if the user enters that word. So if you want the password to be "bananas" the outcome will always be false. You need to store the password (Either in a text file, or, for not, in a constant variable) and then check if that word, is the entered word.
Hope this helps :)
"varchar" is typically associated with MYSQL datatypes.. What field do you want to make/add "varchar" to?
Yeah, like @Javvy said just use HTML tags.. So something like this:
<?php
date_default_timezone_set('UTC');
$d = date("M");
echo "<font color='yellow'>$d</font>";
?>
@TKO, no harm made..
Are you clear what you want the script to do yet ha?
@diafol The user requires something different to what they are posting. He wants the script to remember the option that they selected, without using Database. Any suggestions other than cookies? (Obviously they would expire after a set amount of time)! I can't think of any other way.
Finally got there:
<?php
$arr = array(3,5,2,5,3,9);
$temp_array = array();
foreach($arr as $val)
{
if(isset($temp_array[$val]))
{
$temp_array[$val] = $val;
}else{
$temp_array[$val] = 0;
}
}
foreach($temp_array as $val2)
{
if($val2 > 0)
{
echo $val2 . ', ';
}
}
?>
I doubt it will work for words, or characters, for this you will have to manipulate the array_keys.
3, 5,
When creating your table, did you specify the ID (primary_key) was auto increment? If so, you shouldn't have this problem..
Apologies..
It depends where you want to display the information, at one point..
then it could be as simple as (an example):
<div id="phpContent">
<table border='1'>
<tr>
<th>Agent_ID</th>
<th>Address</th>
<th>Bedrooms</th>
<th>Price</th>
<?php
$connect=mysql_connect("localhost","root","");
$db_selected = mysql_select_db("ong_assessment", $connect);
$query = "SELECT Agent_ID,Address,Bedrooms,Price FROM harcouts";
$result = mysql_query($query) or die(mysql_error());
if(!mysql_affected_rows() >= 1)
{
echo 'There are no entries inside the database';
}
while($row = mysql_fetch_array($result))
{
echo '<tr>';
echo '<td>'. $row['Agent_ID'].'</td>';
echo '<td>'. $row['Address'].'</td>';
echo '<td>'. $row['Bedrooms'].'</td>';
echo '<td>'. $row['Price'].'</td>';
}
echo '</table>';
?>
</div>
I suppose it's bad to have HTML/PHP together, in this respect. So it might be better to include this using include('foo.php'); BUT it depends where you want the content to be shown. I haven't seen your page etc.. Remember to save the page as .php instead of .html if you're using PHP.
Before you begin to integrate PHP within this HTML...
This is wrong:
<!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>
<meta name = "description" content = "Wellington Real Estate"/>
<meta name = "keywords" content = "home, housing, Karori, Mirimar, Te Aro, Thorndon, Farcourts, Jonnys, Relax"/>
<title> Agents </title>
<link rel = "stylesheet" type = "text/css" href = "assessment.css"/>
</head>
<body>
<div id = "wrapper">
<div id = "container">
<div id = "banner">
<h1>The Wellington Real Estate Company</h1>
</div>
<div id = "left">
<a href = "Index.html">Home</a>
<a href = "Agents.html">Agents</a>
<a href = "Suburbs.html">Suburbs</a>
</div>
<div id = "right">
<br/>
<h2>Listing of Houses by Agent</h2>
<p>All our agents are currently listing a range of properties. Please click on one of the links to see that agent's listings: </p><br/>
<a href = "Farcourts.php">Farcourts</a>
<a href = "Jonnys.html">Jonnys</a>
<a href = "Relax.html">Relax</a>
</div>
</div>
</div>
</body>
</html>
<body>
<div id = "wrapper">
<div id = "container">
<div id = "banner">
<h1>The Wellington Real Estate Company</h1>
</div>
<div id = "left">
<a href = "Index.html">Home</a>
<a href = "Agents.html">Agents</a>
<a href = "Suburbs.html">Suburbs</a>
</div>
<div id = "right">
<br/>
<h2>Listing of Houses by Agent</h2>
<p>All our agents are currently listing a range of properties. Please click on one of the links to see that agent's listings: </p><br/>
<a href = "Farcourts.php">Farcourts</a>
<a href = "Jonnys.html">Jonnys</a>
<a href = "Relax.html">Relax</a>
</div>
</div>
</div>
</body>
</html>
If this is solved now, please mark it so and give rep to those who helped you :)!
I think the system should have a feature like "Don't show this again" and then remember it, but, still give them the option (without pop-up) when they create a new thread. I know what you mean!
Do you have an online example of what is happening when you re-fresh? A url or something?
Sign :(!
Try this, change your form values so it has 0 or 1. 0 = false, 1 = true
<?php
$option = $_POST['option'];
if(!isset($option))
{
echo 'You have not submitted an option';
}
switch($option)
{
case 0:
// FALSE
echo 'This is false';
break;
case 1:
// TRUE
// re-direct to link 1;
$new_link = "index.php";
echo 'This is true';
break;
default:
echo 'Invalid option';
break;
}
?>
E.g.
<form method="post">
<input type="radio" name="option" value="1">True</option>
<input tpe="radio" name="option" value="0">False</option>
<input type="submit" name="submit" value="Go!">
Hopefully this will work, let me know!
I've never done this in PHP, but, by 'Binary', i'm guessing that you're trying to parse a binary image? (I.e. black and white)?
Look at the syntax, if you have to explain what the script does, then it's pretty self-explanatory.. I cannot do your work for you, that wouldn't be fair and I'm sure you actually want to learn something ;) I'll help you a bit though:
Explain each line of code:
$connect=mysql_connect("localhost","root","");
$db_selected = mysql_select_db("ong_assessment", $connect);
This code establishes a connection with the database on the server. The mysql_connect accepts three parameters. The mysql_select_db attempts to select the database that data will be retrived from. It accepts two parameters, one is the name of the database and the other is the connection variable.
...
...
...
Something like this :)
Yes, but, try and solve the problems yourself :)! But, you're welcome to post here and we'll help you.
If this is solved, please mark it as solved and give rep to those who helped!
Good luck
<head>
</head>
<body>
<table border='1'>
<tr>
<th>Agent_ID</th>
<th>Address</th>
<th>Bedrooms</th>
<th>Price</th>
<?php
$connect=mysql_connect("localhost","root","");
$db_selected = mysql_select_db("ong_assessment", $connect);
$query = "SELECT Agent_ID,Address,Bedrooms,Price FROM suburbs";
$result = mysql_query($query) or die(mysql_error());
if(!mysql_affected_rows() >= 1)
{
echo 'There are no entries inside the database';
}
while($row = mysql_fetch_array($result))
{
echo '<tr>';
echo '<td>'. $row['Agent_ID'].'</td>';
echo '<td>'. $row['Address'].'</td>';
echo '<td>'. $row['Bedrooms'].'</td>';
echo '<td>'. $row['Price'].'</td>';
}
echo '</table>';
?>
</body>
</html>
Better? They're no longer constants (:
Yes, your script is wrong. I posted an altered version the script that fixed the errors you had.
LOOK at the syntax..
<head>
</head>
<body>
<table border='1'>
<tr>
<th>Agent_ID</th>
<th>Address</th>
<th>Bedrooms</th>
<th>Price</th>
<?php
$connect=mysql_connect("localhost","root","");
$db_selected = mysql_select_db("ong_assessment", $connect);
$query = "SELECT Agent_ID,Address,Bedrooms,Price FROM suburbs";
$result = mysql_query($query) or die(mysql_error());
if(!mysql_affected_rows() >= 1)
{
echo 'There are no entries inside the database';
}
while($row = mysql_fetch_array($result))
{
echo '<tr>';
echo '<td>'. $row[Agent_ID].'</td>';
echo '<td>'. $row[Address].'</td>';
echo '<td>'. $row[Bedrooms].'</td>';
echo '<td>'. $row[Price].'</td>';
}
echo '</table>';
?>
</body>
</html>
Now, if the output is: 'There are no entries inside the database' then there are no records in the table 'suburbs'. There are NO errors now, don't create errors for yourself.
Please post your script, how it looks now.. Removing any passwords etc..
Now you have to insert data, for the data to be shown :) Do you use mysqladmin? If so, you can just throw some example data in just to test!
Ok, try this:
where you have:
mysql_select_db("ong_assesment",$connect);
change it to:
$db_selected = mysql_select_db("ong_assesment", $connect);
Making sure, your database name is called "ong_assesment".
Is there a database called "ong_assesment"