wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
Add the following lines at the top of your page. ini_set('display_errors', 1); error_reporting(E_ALL); It should display any errors
-
Is the /html/ folder your websites root folder? You could use the following as the path $_SERVER['DOCUMENT_ROOT'] . '/files/hotsheet/' . $_FILES["file"]["name"]
-
Your code replies on a setting called register_globals to be enabled in order for it to work properly, your new server most probably has this setting disabled. register_globals has been disabled since the release of PHP4.2 (which was released way back in 2002). Basically all you need to do is, instead of using the variable $name_of_from_field to grab the value from one of your form fields, you'd instead use the $_POST superglobal, eg $_POST['msg'] to get the value from the form field named as msg, for the form field named as email you'd use $_POST['email']
-
When comparing values use == = is used for assigning values.
-
Too many "0" in my tables . . . how do I fix this?
wildteen88 replied to CountryGirl's topic in PHP Coding Help
Misread the OP. If its a year then why use double,? Why not just use INT if you're storing years. -
Too many "0" in my tables . . . how do I fix this?
wildteen88 replied to CountryGirl's topic in PHP Coding Help
Set your field type to double(15,2). Now numbers will only have two decimal places, eg 123.45 -
To get the selected county from your drop down menu you'd use $_POST['cty']. Example if(isset($_POST['cty'])) { $county = mysql_real_escape_string($_POST['cty']); $query = "SELECT * FROM representatives WHERE serves LIKE %($county)%"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { // display results from query } }
-
Where are the variables $logoutform and $loginform defined?
-
Open txt file - Remove all blank lines and save txt file.
wildteen88 replied to new2code's topic in PHP Coding Help
fopen only returns a handle, it doesn't return the text in the file. To read the text from the file you need to use fread. To write to the file you'll need to use fwrite. Seeing as you're reading and writing to the file you'll need to use w+ as the file mode parameter , rather than using w -
Change your form code to //Main Courses (non-vegetarian) echo '<h3>Main Courses (non-vegetarian)</h3>'; $query = mysql_query("SELECT * FROM `menu` WHERE category = 'entree'"); $i = 0; while($row = mysql_fetch_array($query)) { echo '<input type="checkbox" name="title[$i]" value="' . $row['title'] . '" /><b><span id=text_black>' . $row['title'] . '</span> - Quantity: <input type=text name="quantity[$i]" maxlength=1 size=1> - Spice Level: <select name="spice_level[$i]"> <option value=Mild>Mild</option> <option value=Medium>Medium</option> <option value=Hot>Hot</option> <option value=Extra Hot>Extra Hot</option> </select></b> <span id="text_black">- $' . $row['price'] . '<br><i>' . $row['description'] . '</i></span> <br><br>'; $i++; } When you process the form use $item=$_POST['title']; $_SESSION['items'] = $item; foreach ($item as $itemkey => $itemname) { $query = mysql_query("SELECT * FROM `menu` WHERE title = '$itemname'"); while($row = mysql_fetch_array($query)) { $total = $total + $row['price']; $_SESSION['quantity'] = $_POST['quantity'][$itemkey]; echo "<p>" . $_SESSION['quantity'] . " " . $row['title'] . " - <span style=color:#000;>$" . $row['price'] . "</span></p>"; $_SESSION['total'] = $total; } }
-
As long as PHP is able to find the file you are trying to include then all variables should work fine. When developing your script it is recommend to set error_reporting to E_ALL and enable display_errors, for example place these two lines at the top of your script. These lines will temporarily enable errors ini_set('display_errors', 1); error_reporting(E_ALL); Can you post the code you have issues with.
-
Just replace those line with mysql_connect and mysql_select_db.
-
To get the number of results a query returned use mysql_num_rows, example $total_rows = mysql_num_rows(QUERY RESULT VARIABLE HERE); To set the background color based on what $total_rows is set to you'd use an if/elseif/else statement // set $bgcolor based $total_rows // if $total_rows is equal to 3, bcolor is set to red if($total_rows == 3) $bgcolor = 'red'; // if $total_rows is greater than 3, bcolor is set to blue elseif($total_rows > 3) $bgcolor = 'blue'; // $total_rows is not equal to 3 or is not greater than 3, bgcolor is set to white else $bgcolor = 'white'; To change the background of the table you can either use the bgcolor html attribute, example <table bgcolor="<?php echo $bgcolor; ?>"> <tr><td>some cells</td></tr> </table> Or using (inline ) CSS, example <table style="background-color: <?php echo $bgcolor; ?>"> <tr><td>some cells</td></tr> </table>
-
It wont be done by PHP. But it is most probably done using a JavaScript library such as jQuery, mooTools etc.
-
So this is better? <!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 http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Son of Mini-Missions - Home</title> <style type="text/css"> <!-- body { background-image: url(http://www.jservers.co.uk/imgs/bg.png); background-repeat: repeat; } #apDiv1 { position:absolute; left:541px; top:296px; width:266px; height:26px; z-index:1; font-size: 16px; font-family: Georgia, "Times New Roman", Times, serif; font-weight: bold; } .loginHolder tr td b { font-weight: bold; } --> </style></head> <body> <div align="center"> <p><a href="index.php"><img src="logo.jpg" width="648" height="144" /></a></p> <table class="loginHolder"> <tr> <td><b>Player Name</b></td> <td><b>Password:</b></td> </tr> <tr> <td height="24"><form action="login.php" method="post"><input name="username" type="text" value="My_SonofMM_PlayerName" /></td> <td><input name="password" type="password" id="loginPassword" value="MyPassword" /></form></td> </tr> </table> <form action="login.php" method="post"> <input type="submit" name="button" id="button" value="Login" /> </form> <hr /> <p align="center"> </p> </div> </body> </html> No your form tags are still in the wrong location. It should be <!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 http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Son of Mini-Missions - Home</title> <style type="text/css"> <!-- body { background-image: url(http://www.jservers.co.uk/imgs/bg.png); background-repeat: repeat; } #apDiv1 { position:absolute; left:541px; top:296px; width:266px; height:26px; z-index:1; font-size: 16px; font-family: Georgia, "Times New Roman", Times, serif; font-weight: bold; } .loginHolder tr td b { font-weight: bold; } --> </style></head> <body> <div align="center"> <p><a href="index.php"><img src="logo.jpg" width="648" height="144" /></a></p> <form action="login.php" method="post"> <table class="loginHolder"> <tr> <td><b>Player Name</b></td> <td><b>Password:</b></td> </tr> <tr> <td height="24"><input name="username" type="text" value="My_SonofMM_PlayerName" /></td> <td><input name="password" type="password" id="loginPassword" value="MyPassword" /></td> </tr> </table> <input type="submit" name="button" id="button" value="Login" /> </form> <hr /> <p align="center"> </p> </div> </body> </html>
-
My counter is counting even when $_SESSIONS isset
wildteen88 replied to jmr3460's topic in PHP Coding Help
Also note that this code $sql = "SELECT * FROM $table WHERE page_name = '$page'"; $get_count = mysql_query($sql) or trigger_error(mysql_error()); $result_count = mysql_fetch_array($get_count); $pre_count = $result_count['count']; $add_count = $pre_count + 1; $add_sql = "UPDATE $table SET count = '$add_count' WHERE page_name = '$page'"; $add_query = mysql_query($add_sql) or trigger_error(mysql_error()); $count = $add_count; can be written as just two lines $add_sql = "UPDATE $table SET count = count+1 WHERE page_name = '$page'"; $add_query = mysql_query($add_sql) or trigger_error(mysql_error()); -
You may want to use implode instead. <?php foreach ($result4 as $row4) $rows[] = $row4->n_lingua; echo implode(',', $rows); ?>
-
What the! How is it getting a match with no username and password! What is the username and password you're using?
-
Woops. Try <?php $myusername = mysql_real_escape_string(stripslashes($_POST['username'])); $mypassword = mysql_real_escape_string(stripslashes($_POST['mypassword'])); $result = mysql_query("SELECT * FROM users WHERE Name = '$myusername' AND Password='$mypassword'"); $count = mysql_num_rows($result); if($count==1) { session_register("myusername"); session_register("mypassword"); header("location:login_success.php"); } else { echo '<h1>DEBUG IT</h1>'; echo '<p>Match Username (<i>'.$myusername.'</i>)... '; $query = mysql_query("SELECT Password FROM users WHERE name='$myusername'"); if(mysql_num_rows($query) > 0) { echo 'SUCCESS'; echo '<p>Match password... '; list($dbPassword) = mysql_fetch_row($query); if($mypassword == $dbPassword) echo 'SUCCESS'; else { echo 'FAIL!'; echo '<p>Password is wrong what is it?<br />'; echo '$mypassword = \''.$mypassword.'\'<br />'; echo '$dbPassword = \''.$dbPassword.'\''; } } else { echo 'FAIL!'; } echo "Wrong Username or Password. please go back."; } ?>
-
I have added some debug code. <?php $myusername = mysql_real_escape_string(stripslashes($_POST['username'])); $mypassword = mysql_real_escape_string(stripslashes($_POST['mypassword'])); $result = mysql_query("SELECT * FROM users WHERE Name = '$myusername' AND Password='$mypassword'"); $count = mysql_num_rows($result); if($count==1) { session_register("myusername"); session_register("mypassword"); header("location:login_success.php"); } else { echo '<h1>DEBUG IT</h1>'; echo '<p>Match Username (<i>'.$myUsername.'</i>)... '; $query = mysql_query("SELECT Password FROM users WHERE name='$myusername'"); if(mysql_num_rows($query) > 0) { echo 'SUCCESS'; echo '<p>Match password... '; list($dbPassword) = mysql_fetch_row($query); if($myPassword == $dbPassword) echo 'SUCCESS'; else { echo 'FAIL!'; echo '<p>Password is wrong what is it?'; echo '$myPassword = \''.$myPassword.'\'<br />'; echo '$dbPassword = \''.$dbPassword.'\''; } } else { echo 'FAIL!'; } echo "Wrong Username or Password. please go back."; } ?> Run that code and post the output. Make sure you are filling in your login form and running the above code directly.
-
Just looking at your code again. Where are you connecting to your database?
-
How are your storing your password in the database? Do you use any form of encryption? Such as md5, sha1 etc.
-
Can you post the error your are getting?
-
You should look into using SQL Joins. Joins allow you to query more than one table at a time.
-
You have a syntax error in your query The characters in red should be a comma. Also you should never place raw _POST data straight into an SQL query. You should always sanitize user input.