peranha
Members-
Posts
878 -
Joined
-
Last visited
Everything posted by peranha
-
[SOLVED] $id = $_GET['id'] - can't get it to work :(
peranha replied to selliott's topic in Microsoft SQL - MSSQL
$_GET gets information from the url, not the database. -
[SOLVED] Is there an easy way to prevent SQL injection?
peranha replied to 3motions's topic in PHP Coding Help
yeah you can -
[SOLVED] Is there an easy way to prevent SQL injection?
peranha replied to 3motions's topic in PHP Coding Help
do you have a function that cleans data already as far as other things. if so just add mysql_real_escape_string() to the function. -
[SOLVED] My code is creating two MySQL entries.. Weird?
peranha replied to 3motions's topic in PHP Coding Help
try changing this section of code $addnew1=$_GET["addnew"]; if($addnew1=='1'){ $add_offername=$_POST["add_offername"]; $add_urlrewrite=$_POST["add_urlrewrite"]; $add_description=$_POST["add_description"]; $add_url=$_POST["add_url"]; $add_points=$_POST["add_points"]; $add_level=$_POST["add_level"]; mysql_query("insert into offers (offerid,title,titlerewrite,description,url,pointworth,level,active)". "VALUES ('NULL','$add_offername','$add_urlrewrite','$add_description','$add_url','$add_points','$add_level','1')"); echo "<b>* The new offer has been added to the database.</b><br>"; echo "<br>"; } to if (isset($_POST['addnew'] { $addnew1=$_GET["addnew"]; if($addnew1=='1'){ $add_offername=$_POST["add_offername"]; $add_urlrewrite=$_POST["add_urlrewrite"]; $add_description=$_POST["add_description"]; $add_url=$_POST["add_url"]; $add_points=$_POST["add_points"]; $add_level=$_POST["add_level"]; mysql_query("insert into offers (offerid,title,titlerewrite,description,url,pointworth,level,active)". "VALUES ('NULL','$add_offername','$add_urlrewrite','$add_description','$add_url','$add_points','$add_level','1')"); echo "<b>* The new offer has been added to the database.</b><br>"; echo "<br>"; } } You never check to see if submit is pressed. -
Simple Problem! Not complex, well I don't think so!
peranha replied to stig1's topic in PHP Coding Help
Chang this line $percent = $products["percent"]; to this $percent = $margins["percent"]; -
42: $i++ I believe that should be 42: $i++;
-
I just moved the no results section to the bottom of the page, and the links in the loop that if results are found.
-
I dont think it is mysql. If you are using apache, I believe this is what you want. Look for a line that says this in the config file. ServerAdmin webmaster@website.com
-
Not a problem, glad it is working fine. Please mark the topic as solved. There is a button on the bottom left under the last post.
-
This is what I use for my pagination, I have png files with arrows on them, and it shows them, but it doesnt make the link active if there is only 1 page, or no pages at all. If you want, just put your < > in the place of the images and it will show them instead. It should work. if ($pageno == 1) { echo "<img src='pics/first.png' alt='' /> <img src='pics/previous.png' alt=''/> "; } else { echo " <a href='{$_SERVER['PHP_SELF']}?pageno=1'><img src='pics/first.png' alt=''/></a> "; $prevpage = $pageno-1; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage'><img src='pics/previous.png' alt=''/></a> "; } // if echo " ( Page $pageno of $lastpage ) "; if ($pageno == $lastpage) { echo " <img src='pics/next.png' alt=''/> <img src='pics/last.png' alt=''/>"; } else { $nextpage = $pageno+1; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'><img src='pics/next.png' alt=''/></a>"; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$lastpage'><img src='pics/last.png' alt=''/></a>"; } // if
-
You can try this and see if it works the way you want it to. I rearrange the logic a little, and I didnt test it, but should work. <?php // database connection info $conn = mysql_connect('localhost','root', 'pass') or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db('database', $conn) or trigger_error("SQL", E_USER_ERROR); // find out how many rows are in the table $sql = "SELECT COUNT(*) FROM table"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); $r = mysql_fetch_row($result); $numrows = $r[0]; // number of rows to show per page $rowsperpage = 5; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; // get the info from the db $sql = "SELECT * FROM table LIMIT $offset, $rowsperpage"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); if(mysql_num_rows($result) > 1){ while($row = mysql_fetch_assoc($result)) { // echo results from search. echo "Results"; } // end while /****** build the pagination links ******/ // if not on page 1, show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } // end if // range of num links to show $range = 3; // loop to show links to range of pages around current page for ($x = (($currentpage - $range) - 1); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [$x] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; // echo forward link for lastpage echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ } // end else else { echo "<p>No results.</p>"; } ?>
-
The logic of the page will have to be redone. A die statement stops the script from running after that point.
-
Then change these lines { echo "<p>No results.</p>"; } to { echo "<p>No results.</p>"; die(); }
-
PHP & MySQL - Not Inserting Rows when within Foreach loop
peranha replied to johnslater's topic in PHP Coding Help
$query1 = "INSERT INTO `slaterjohn`.`minifeed` (`miniID`, `feedtitle`, `itemtitle`, `itemdate`, `itemlink`, `itembody`, `favico`) VALUES (NULL , '1', '2', '3', '4', '5', '6')"; mysql_query($query1); Try that, I took out the first ; in the query. you dont need it -
On the page do yo get "No results" with the linkable carrots (< << >> >)
-
Put this in a different file call it getimage.php <?php $path = $_GET['id']; $extension = substr($path, -3); if($extension == "jpg" || $extension == "jpeg"){ header("Content-type: image/jpeg"); }elseif($extension == "gif"){ header("Content-type: image/gif"); }elseif($extension == "bmp"){ header("Content-type: image/bmp"); } readfile($path); ?> then on your page call it like this echo "<img src='getimage.php?id=" . $destination . "' alt='' />"; This worked on my server.
-
<?php $path = 'c:\wamp\tmp'."\\".$_FILES['pix']['name']; $extension = substr($path, -3); if($extension == "jpg" || $extension == "jpeg"){ header("Content-type: image/jpeg"); }elseif($extension == "gif"){ header("Content-type: image/gif"); }elseif($extension == "bmp"){ header("Content-type: image/bmp"); } readfile($path); ?> echo "<img src='$path' />"; try that and see what you get.
-
dont you save the name of the file in a database or something? If not, I would, and if it is only displayed once, you can use this to display it once $_FILES['pix']['name']
-
<img src='path_to_pic.jpg' alt='' />
-
Add http:// in front of it, mine works fine in hotmail this is what I have. $message.="http://www.website.com/confirmation.php?passkey=$uniqueid \r\n";
-
Also you need to change you query to $result = mysql_query("select Email, user, etc... from Accounts where AccountID='$_POST[username]'") or die(mysql_error()); from $result = mysql_query("select Email from Accounts where AccountID='$_POST[username]'") or die(mysql_error());
-
yes you would $accemail = $row[0]; $accname = $row[1]; etc. row[1], may not be the name, not sure how your database is set up.
-
thats because you are not checking the database to make sure that the info matches it. you will have to do something similar to this for all fields else if ($_POST['oldemail'] != $accemail) { echo "email invalid."; echo '<a href="email.php">Return to email page</a>'; die(); }
-
try adding http:// in front of it do you know if it is a specific email server that is doing this, I havent had any problems, but I have http:// in front of mine.