wildteen88
-
Posts
10,480 -
Joined
-
Last visited
Never
Posts posted by wildteen88
-
-
if your are suing session make sure you have session_start on everypage that uses sessions.
-
change [b]id="message"[/b] to [b]name="message"[/b] and you should be fine.
Also chnage your PHP block to this:
[code]<?php
if(isset($_POST['message']))
{
echo $_POST['message'];
}
?>[/code] -
If you are getting that error message then you'll find that you have too many open and closing braces - {} - make sure they all pair up also make sure you parenthesis pair up too ()
One thing I can tell you that can help you make sure you braces pair up is indent your code. Have a look at your code now:
[code]<?php
// Get the 'username' varible from flash
$username = $_POST['username'];
$guessfirstname = $_POST['firstname'];
$guessid = $_POST['id'];
// Start database connection
$dbcnx = @mysql_connect("localhost","alexg_si","password");
if (!$dbcnx)
{
echo "Unable to connect to the database server at this time.";
exit();
}
mysql_select_db("alexg_web", $dbcnx);
$result = @mysql_query("SELECT guessed, guessedright FROM whoamipeople WHERE id = '$guessid'");
if (!$result)
{
exit("<p>Error performing query: " . mysql_error() . "</p>");
}
// Disply the users Account Details $row["Clue"]
while ($row = mysql_fetch_array($result))
{
$oldguessed = $row["guessed"];
$addingone = '1';
$newguessed = $oldguessed + $addingone;
$oldguessedright = $row["guessedright"];
$newguessedright = $oldguessedright + $addingone;
}
// done adding one
mysql_select_db("alexg_web",$dbcnx);
$resultupdateguess = @mysql_query("UPDATE whoamipeople SET guessed = '$newguessed', guessedright = '$newguessedright' WHERE Firstname = '$guessfirstname'");
$resultupdateguessisitright = @mysql_query("SELECT guessedright FROM whoamipeople WHERE id = '$guessid'");
while ($rowright = mysql_fetch_array($resultupdateguessisitright))
{
$oldguessedrightisitright = $rowright["guessedright"];
if ($oldguessedrightisitright == $newguessedright)
{
echo "<p>Thank You, Processing Your Guess.</p>";
$resultupdateguesscorrect = @mysql_query("UPDATE whoamipeople SET score + 100 WHERE Username = '$username'");
echo "<p>Checking if guessed firstname is a match in the Who Am I? Database...</p>";
echo "<p>Yes! That is correct! You have gained 100 points. Check out your Account Info for your score!</p>";
}
else
{
echo "<p>Checking if guessed firstname is a match in the Who Am I? Database...</p>";
echo "<p>Sorry, that is the incorrect name. Nice Try!</p>";
}
} //this was your missing backet!
// swich back to html mode to create divider
//
?>[/code]As you can see your code is much more readable and easy to identify code blocks, just press your tab key once when you go into a code block, ie a if statement, while loop, creating functions etc. -
Are you using Dreamweaver 8? If so this is normal behaviour and it doesnt affect the total number of lines available. The reason Dreamweaver does this to help you not have to scroll horizontally if a line gets too large. The lines are still the same just that some lines are taller than others.
You can Stop DW8 from doing this by going to View -> Code View Options and deselect [b]Word Wrap[/b] DW8 should disply your code normally rather than having like:
1
2
3
4
etc -
What do you mean by other variables. If it is variables being passed through the url, ie page.php?var=value1&var2=value2 Then you'll need to place in the header redirect itself like so:
[code]header("page.php?var=value1&var2=value2");[/code]
If you have POST'd data from a form or any other variables then no you will need to either pass these over the URL or use a session to store these on the server and you'll be able to use them on the page that you are redirecting the usert to. -
Have a look at sessions. Just create three session win, lose and draw. Then just add a single line of code:[code]$_SESSION['win'] += 1;[/code] when the user wins or do [code]$_SESSION['lose'] += 1;[/code] or [code]$_SESSION['draw'] += 1;[/code] when the user draws.
I ahve implemented this into your script, aswell as recode it. You'll soon see the difference and your code is alot more slimmer than before! Heres you new code:[code]<?php
session_start();
?>
<html>
<body link="#000000" vlink="#000000" alink="#000000">
<center>
<?php
//first check that our wins, loses and draws sessions aren't set so we dont reset them everytime we play agaion as we want to
//keep our total wins, loses and draws
if(!isset($_SESSION['wins']) || !isset($_SESSION['loses']) || !isset($_SESSION['draws']))
{
$_SESSION['wins'] = 'no';
$_SESSION['loses'] = 'no';
$_SESSION['draws'] = 'no';
}
$computer = rand(1,3);
if ($computer == 1) $choice = 'Rock';
if ($computer == 2) $choice = 'Paper';
if ($computer == 3) $choice = 'Scissors';
//This here is a normal if/else statement but its just an inline if/else statment
$action = (isset($_GET['action']) ? $_GET['action'] : '');
if ($action == 'Rock' && $choice == 'Rock') {
echo "You Choose $action vs. Computer Choose $choice<br />No One Won";
//we drew here so lets increse the draws sesion by one
$_SESSION['draws'] += 1;
}
elseif ($action == 'Rock' && $choice == 'Paper') {
echo "You Choose <b>$action</b> vs. Computer Choose <b>$choice</b> <br> You Lost";
//we lost here so lets increse the loses sesion by one
$_SESSION['loses'] += 1;
}
elseif ($action == 'Rock' && $choice == 'Scissors') {
echo "You Choose $action vs. Computer Choose <b>$choice</b> <br> You Won</html>";
//we won here so lets increse the wins sesion by one
$_SESSION['wins'] += 1;
}
elseif ($action == 'Paper' && $choice == 'Rock') {
echo "You Choose <b>$action</b> vs. Computer Choose <b>$choice</b><br> You Won";
$_SESSION['wins'] += 1;
}
elseif ($action == 'Paper' && $choice == 'Scissors') {
echo "You Choose <b>$action</b> vs. Computer Choose <b>$choice</b> <br> You Lost";
$_SESSION['loses'] += 1;
}
elseif ($action == 'Paper' && $choice == 'Paper') {
echo "You Choose <b>$action</b> vs. Computer Choose <b>$choice</b> <br> No One Won";
$_SESSION['draws'] += 1;
}
elseif ($action == 'Scissors' && $choice == 'Rock') {
echo "You Choose <b>$action</b> vs. Computer Choose <b>$choice</b> <br> You Lost";
$_SESSION['loses'] += 1;
}
elseif ($action == 'Scissors' && $choice == 'Paper') {
echo "You Choose <b>$action</b> vs. Computer Choose <b>$choice</b> <br> You Won";
//we won here so lets increse the wins sesion by one
$_SESSION['wins'] += 1;
}
elseif ($action == 'Scissors' && $choice == 'Scissors') {
echo "You Choose <b>$action</b> vs. Computer Choose <b>$choice</b> <br> No One Won";
$_SESSION['loses'] += 1;
}
echo "<br /><hr><br />";
echo "You have won a total of <b>" . $_SESSION['wins'] . "</b> times<br />";
echo "You have lost a total of <b>" . $_SESSION['loses'] . "</b> times<br />";
echo "You have drew a total of <b>" . $_SESSION['draws'] . "</b> times<br /><br />";
?>
<a href="?action=Rock"><img src="Rock.bmp"></a>
<a href="?action=Paper"><img src="Paper.bmp"></a>
<a href="?action=Scissors"><img src="Scissors.bmp"></a>
</html>[/code]
-
I have found out why your links are not returning an id value becuase you are using a variable called $id which doesnt even exist, as you are using the wrong variable/function to retrieve the tutorial id from the manual:
[code]if(mysql_num_rows($result) > 0)
{
while($row = mysql_fetch_row($result))
{
?>
<table width="100%">
<tr>
<td width="40"><img src="<?php echo $imagen; ?>" alt="<?php echo $titulo; ?>"></td>
<td><span class='style20 Estilo3'><?php echo $id; ?>: <?php echo $titulo; ?><br /><a href="editar.php?id=<?php echo $id; ?>">Editar</a> | <a href="borrar.php?id=<?php echo $id; ?>" onClick="return confirm('¿Seguro que quieres borrarlo?')">Borrar</a></span></td>
</tr>
</table>
<hr>
<?php
}
}[/code] Notice your while loop you are using mysql_fetch_row. This will return variables as follows:
$row[0], $row[1], $row[2] etc depending on how many rows have been returned from the query. It does not return variables such as $titulo, $id.
Instead you will have to setup the variables $id and $titulo like so:
[code] while($row = mysql_fetch_row($result))
{
$titulo = $row[0];
$id = $row[1][/code]
Now your link should be showing the id.
If you are unsure have a look at how you are returning your mysql results in tutorial.php as that is the correct. -
PHP is not like HTML where you can go to anyones site and see their HTML source. With PHP your code is the [b]input[/b] (or source code) then the server (PHP intepreter) [b]processes[/b] your code and so you end up with the [b]output[/b] which is the HTML or plain text.
HTML on the other hand is not process by the server however it is by the browser it self. The same with CSS and Javascript.
You cannot get anyones source code by doing view source or by downloading the file as that will just provide you with the output of the script. The only way for you to see the true source code of someones script is if they provide a download of their script, which I dought or you have FTP access to where the PHP files are kept. -
There is no reason for you to use ob_start(); for what high-tek has posted!
-
You might want to read through the [a href=\"http://www.phpfreaks.com/tutorials/65/0.php\" target=\"_blank\"]Membership[/a] tutorial over at the main site of phpfreaks.com in the tutorial section which you can go to by clicking ther link I have posted.
That tutorial wont give you all the info you need to do your system but it;ll provide the basics of creating a membership system which will be the basis of your script that you are planning one doing. -
To find out why your sql query is failing chnage your query line to this:
[code]$query=mysql_query("SELECT * FROM $tablename WHERE show ='yes' ORDER BY player asc") or die("Error with query: " . mysql_error());[/code]When you run your query again MySQL will report back why your query is failing.
However I think MySQL maybe getting confused as show is a predefined word in mySQL so if you surround show in backticks like so: `show` it may help. -
It returns [i]Yuo haven't filled in anything[/i] for me as its reaching the else statement
-
Yes you can you just have to make another query to the database after your other query. I believe this is your query:[code] $updateSQL = sprintf("UPDATE brokers SET broker_rating= broker_rating + %s, broker_num_votes=%s + 1 WHERE id=%s",
GetSQLValueString($_POST['broker_rating'], "int"),
GetSQLValueString($_POST['broker_num_votes'], "int"),
GetSQLValueString($_POST['id'], "int"));
mysql_select_db($database_broker, $broker);
$Result1 = mysql_query($updateSQL, $broker) or die(mysql_error());[/code]After [i]GetSQLValueString($_POST['id'], "int"));[/i] do your secound query to log the users IP address. -
Something like this?
[code]<?php
if(isset($_GET['dname']) && isset($_GET['dtld']))
{
$dname = $_GET['dname'];
$dtpl = $_GET['dtld'];
echo "Your domain name is: <b>" . $dname . $dtpl . "</b><br /><br />";
}
?>
<form name="dOrder" action="<?php $_SERVER['PHP_SELF']; ?>" method="get">
Domain Name: <input type="text" name="dname" />
tld: <select name="dtld">
<option value=".com">.com</option>
<option value=".co.uk">.co.uk</option>
<option value=".biz">.biz</option>
<option value=".net">.net</option>
<option value=".org.uk">.org.uk</option>
</select>
</form>
<input type="button" name="submit" value="Order Domain" onClick="document.dOrder.submit()"/>[/code] -
Umm, thats for coldfusion which is totally different to PHP!
-
I agree with redbullmarky here. Just sitck your mail function right after the insert query when an alert is added. Its the best possible solution to this.
To make PHP email you it will only take one line of code, or a few lines to setup the message part of the email and the headers too. 10 lines max. -
What do you mean by location output? Also I dont think there is any other function in PHP that can redirect the user appart from header. As header tells the browser what to do.
-
Change the following:
[code]<button onclick="window.location='sold.php?id=<? echo $row_p['id']; ?>'" value="No"><? echo $sold; ?></button>[/code]to this:
[code]<input type="button" onclick="window.location='sold.php?id=<? echo $row_p['id']; ?>'" value="<?php echo $sold; ?>">[/code] -
To strip any new line chars use this:
[code]str_replace(array("\r", "\n"), "", $event[descrip])[/code]It is very important that you use double quotes when dealing with whitespace chars otherwise PHP will treat them as normal characters if you are using single quotes. -
Do you want [i]rel="lightbox"[/i] to passed over the URL or do want it to be as an attribute as I dont know where you want it. If you want it be passed over the URL then use this:
[code]'<a href="'.$gallery_uri.'file='.$current.$path['basename'].'&rel=lightbox">'.$path['basename'].'</a>'[/code]or if as an attrubute use this:
[code]'<a href="'.$gallery_uri.'file='.$current.$path['basename'].'" rel="lightbox">'.$path['basename'].'</a>'[/code] -
If you have lots of HTML then just go in and out of PHP, as PHP is able to d this with ease whereas other langauges cant so do this:
[code]<?php
// your php code here
?>
Your html here
<?php
// alittle more PHP
?>
The remaining HTML[/code] -
Actually you can use css on a browse button you can not hide trhe browser button and use a custom made one to submit an upload. I think the syntax for styling a file control box is this:
[code]input[type=file] {
//css code is here
}[/code] -
If your questnook is being attacked then its down poor validation /coding when someone posts a message. Never trust what a user submits always validate user input. By not allowing them to post HTML/Javascript as this is why your guestbook is being attacked.
If you want HTML to be posted but only a certain HTML tags uses strup_tags with the secound flag like so:
strip_tags($_POST['message'], "<b><u><i><p>");
strip_tags will now strip all html tags accept <b>, <u>, <i> and <p>!
If you implement that it wont make your script bullet proof but it can help prevent spammers adding links/javascript etc. -
Do you mean is there a way for PHP to find the links that result in a 404 error message. As far as I know there isn't anyway to do that. However you can use $_SERVER['HTTP_REFERER'] this will return the page that the user last came from, so I guess this can help you alittile but there isn't away with PHP to find dead links.
connect to mysql on one server from another
in PHP Coding Help
Posted
[code]mysql_connect("example.com:3306", "userName", "passWord")[/code]