premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
$sql is not defined. Inside functions variables set there are local to that function. If you want to use a defined sql statement pass it as a parameter. <?php myFunc("SELECT * FROM tabl"); function myFunc($sql) { $query = mysql_query($sql); $rows = mysql_num_rows($query); $last = ceil($rows/$numrows); if (isset($_GET['page'])){ $page = $_GET['page']; } else { $page = 1; } $page = (int)$page; if ($page > $last){ $page = $last; } if ($page < 1){ $page=1; } $limit = 'LIMIT ' .($page - 1) * $numrows .',' .$numrows. ';'; $query = mysql_query($sql.$limit); return true; } ?> Hope that helps you understand. http://us3.php.net/manual/en/language.variables.scope.php For more information on what I am talking about.
-
You are not requerying the data. mysql_data_seek <?php $sql = "SELECT * FROM runningbacks"; $RBs_set = mysql_query($sql, $connection); if (!$RBs_set) { die("Database query failed: " . mysql_error()); } else { for($x=1; $x<=2; $x++){ echo "\n<tr><td>RB</td>"; echo "\n<td><select name=\"RunningBacks\"/>"; echo "\n<option class='' value=''></option>"; mysql_data_seek($RBs_set, 0); // reset pointer to 0. while ($RBsArray = mysql_fetch_array($RBs_set)) { for($y=0; $y<count($RBsArray); $y++){ $playerid = $y+1; echo "\n<option class='' value='{$playerid}'>{$RBsArray[$y]}</option>"; } } echo "\n</select>"; echo "\n</td>"; echo "</tr>"; } } ?>
-
Umm setup the user register/login system. Then using a mysql database populate session data with the "donator" array index. If "donator" is set to 1 or true, than they can view those webpages else redirect them to the home page or a page they can view.
-
Could be, are you using the <?php and ?> tags. If you are using the <? chances are short_tags are turned off use the <?php instead.
-
Call or talk with your host and see how you must upload php files. Chances are you are uploading them wrong, or php is a switch that your host needs to turn on.
-
You have to upload the code using the .php file extension or else it will just show text.
-
Need to query mysql databe with random number of variables from a post
premiso replied to billgod's topic in PHP Coding Help
ummm Post some of your code for better help. It is hard to code "blind" as it be. <?php foreach ($_POST as $key => $val) { if (stristr($key, "chk")) { $ids[] = $val; } } $ids = implode(", ", $val); $sql = "SELECT * FROM table_name WHERE column IN(" . $ids . ")"; $res = mysql_query($sql); while ($row = mysql_fetch_assoc($res)) { // etc etc } ?> The above is assuming that in your form you use "chk" as part of each checkbox's name. -
using checkboxes to post different values
premiso replied to overlordofevil's topic in PHP Coding Help
$amt = $_POST['amt']; $reason = $_POST['reason']; Remove the spaces between $_POST and [. I do not think that is kosher (but not 100% sure) I would brush up on your html for forms: <input type='int' name='amt' size='5'></td><td><input type='reason' name='reason' size='20'> That should be: <input type='text' name='amt' size='5'></td><td><input type='text' name='reason' size='20'> There is no such type as int or reason for forms in HTML. -
[SOLVED] I want to be able to count an item once using COUNT(*)
premiso replied to jeger003's topic in PHP Coding Help
<?php $query = "SELECT COUNT(VisIP) as ipCount FROM logs GROUP BY VisIP"; $result = mysql_query($query) or die(mysql_error()); // Print out result while($row = mysql_fetch_array($result)){ echo "". $row['ipCount'] ."ips" ; echo "<br />"; } Try that, having the visIP column in there on it's own essentially throws off the group by and doing an actual count. (I think the above is right but I am not 100% sure) -
Small edit to master's code. He forgot to add the session_start. You will need that at the very top of each page that uses sessions. <?php session_start(); // required before any output for sessions. // run your checks on the values, make sure something was entered etc... // then store the info into session vars $_SESSION['user'] = $_POST['user']; // use your session var echo $_SESSION['user']; ?>
-
Does the logo.php actually work...have you tested that? As far as I can tell it looks like it should work, I am not sure on the PHPMailer and IsHTML portion, but also check that your email client allows HTML and does not convert them to regular text. Also check that images are allowed.
-
odd characters randomly showing up in messages sent using mail() ?
premiso replied to ultrus's topic in PHP Coding Help
Without the offending code you probably will not get much help. -
Yep, your switch statement is setup wrong. I think If's are better for this scenario anyhow. A switch statement is really for when you know what data to expect, let's say for 1 page to do multiple functions. Say I have a page I want to use for adding/deleteing or modfiying an item: <?php $page = isset($_GET['page'])?$_GET['page']:'home'; switch ($page) { case 'add': echo 'Do adding here'; break; case 'delete': echo 'Do your deleteing here'; break; case 'modify': case 'edit': echo 'Do modiying and editing here (since both are the same thing)'; break; case 'home': echo 'Here is the homepage, choose to edit or delete or add.'; break; } ?> Hope that helps you know what a switch is really for.
-
Remember php is CasE SenSitIve <?php session_start(); if(isset($_SESSION['Username'])) { $username = $_SESSION['Username']; // make sure it should be Username and not username for the session part. ?> <p></p> <p><a href="shop.php">Shop</a> </p> <?php //connect mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("textgame") or die(mysql_error()); // switch $HOE = "HOE"; echo "you have bought a hoe!!"; switch ($HOE){ case "not enough gold": $Result = mysql_query("SELECT gold FROM users WHERE username='$username'"); $Row = mysql_fetch_array($Result ); if ($Row < 50) echo "You dont have enough gold to purchase a hoe!!"; break; case "you have already baught a hoe": $Username = $_SESSION['Username']; $query = "SELECT * FROM users_items WHERE username='$username' AND item = 'hoe'"; // needed to be lowercase $username $result = mysql_query($query) or die( mysql_error()); if ($row = mysql_fetch_row($result)) echo "you have already bought a hoe!!"; break; case "HOE": mysql_query("INSERT INTO users_items (username, item) VALUES('$username', 'hoe' ) ") or die(mysql_error()); // also needed to be lowercase $username break; } $Query = "SELECT item FROM users_items WHERE username='$username'"; // also needs to be $username $Result = mysql_query($Query); $Row = mysql_fetch_array($Result); $_SESSION['inventory'] = $Row['item']; } //I added this bracket here ?> Give that a try.
-
Should be.
-
[SOLVED] Inserting a record in to a mySQL Data Base
premiso replied to pluto's topic in PHP Coding Help
$display_block = "<h1>Add an Entry</h1> <form method=\"post\" action=\"$_SERVER[php_SELF]\"> <p><strong>Term:</strong><br> <input type=\"text\" name=\"term\" size=50 maxlength=75> <p><strong>Definition:</strong><br> <input type=\"text\" name=\"definition\" size=50 maxlength=75> <p><strong>Chapter:</strong><br> <input type=\"text\" name=\"chapter\" size=30 maxlength=75> <p><strong>Section:</strong><br> <input type=\"text\" name=\"section\" size=30 maxlength=75> <input type=\"hidden\" name=\"op\" value=\"yes\" /> <p><input type=\"submit\" name=\"submit\" value=\"Add Word\"></p> </form>"; Add it via a hidden input box. I would also surround it in ' (single quotes) when you access it via post: $_POST['op'] -
<?php $folder = "greckle/"; // set this to be "/folder" if the script is included in a folder define("DOC_ROOT", $_SERVER['DOCUMENT_ROOT'] . "/"); define("SITEURL", "http://" . $_SERVER['HTTP_HOST'] . "/" . $folder); include(DOC_ROOT . "connGreckle.php"); For the base that will change every tag on the page with a src or href of "folder/file.php" or "file.php" to have the SITEURL infront of it. <base href="<?php echo SITEURL;?>" /> <img src="logo.jpg"> <!-- this is now "http://www.mysite.com/folder/logo.jpg"
-
Scratch that part about the tmp_name, it should be just name. Kindly point out what you see as line 16, with how the code is pasted it is hard to tell. Thanks.
-
[SOLVED] if else statement inside of another if else statement?
premiso replied to berry05's topic in PHP Coding Help
$Result = mysql_query("SELECT gold FROM users WHERE username='$username'") Need a semi-colon after that. -
SMTP setup. I know this has been answered a thousand times but....
premiso replied to 28rain's topic in PHP Coding Help
Probably, sorry, I had this open from earlier and got side tracked and did not see that my reply did not post so I just it "send" after the verifcation page without checking. My bad. -
Look at the HTML tag "base" <base href="http://www.site.com/foldera" /> Should do it for you.
-
Copy the image url and paste it in your browser, see if it works. If it does not, chances are the URL is pointing to the wrong spot.
-
Oh I see. So, since I'm running it locally, and my site is in a folder named greckle....I have to put greckle for the folder name..... But when it goes live, and its just in the public_html folder, I won't need the $folder = greckle; part? thanks! Yep pretty fancy huh? =)
-
SMTP setup. I know this has been answered a thousand times but....
premiso replied to 28rain's topic in PHP Coding Help
Also a note, google requires the use of TLS (I believe it is) and the port is something in the 900's. Read at googles site on howto setup Outlook to send emails. You also have to authenticate yourself with a username/password.