mike12255
Members-
Posts
439 -
Joined
-
Last visited
-
Days Won
1
Everything posted by mike12255
-
Urg! Almost ready to sell site but last fix "ruined site"
mike12255 replied to mike12255's topic in PHP Coding Help
The problem is that the code below is suposed to stop them from all being on the same line: echo "<tr>"; $cols = 3; // number of columns here $count = 1; $rows = 0; //lets show the images as we find them while ($row = mysql_fetch_array($result)){ extract($row); //when the remainder of count divided by cols is 0 do the following.... if ($count % $cols == 0) { echo "</tr>"; // or close a tr and open a new one, etc.. echo "<tr>"; } $simg = str_replace("../","",$spath); $img = str_replace("../","",$path); echo "<a href=$img class=lightwindow title=ADD author=Kaon caption=$info><img src= $simg border =0></a>"; $count++; } -
well anyway its 12:40 am i got to get some sleep, if you have any questions just ask and ill try to answer them when i get back if somone else hasnt already.
-
<?php for ($i, $i < 4, $i++){ for ($r,$r<4,$r++){ if($row[$i] < $row[$r]){ //then nothing happens because the lower number is higher }else{ //set the var in row'i' to a temp cause its about to get over written $temp = $row[$i]; //overwrite the var at i $row[$i] = $row[$r]; //replace the var at r with the temp variable $row[$r]=$temp; } } } ?> so obviously this wouldnt work if u just took this and extracted it into your code im not that nice but i hope you can get the point from it??
-
not direct answer eh? well what i would do is set up a for loop to run through all the values. Then set var i = to your first value and test to see if its less then the other and if it is then leave it else the other var takes its place ill try to type up a small example before i pass out
-
Np just remember to mark topic as solved P.S a little bit of side info if you have a logout button you can use this to ensure their logged out in the session: <? session_start(); unset($_SESSION['s_username']); session_destroy(); header("Location: login.php"); ?>
-
bah, dont worry about it i just noticed the error now, sad considering it was the first thing i was looking for. On that first peice of code you started the topic off with, after the opening php tags include this: session_start(); and then replace what you got with option two, should work
-
Make this be the first bit of code under the php opening tags and see if u get errors: ini_set('error_reporting', E_ALL);
-
then this line must not be getting executed: $_SESSION['s_username'] = $username; i actually use something similar on a webpage im designing for a client and when the user clicks submit i execute this: <?php //better make sure they actually hit submit first if (isset($_POST['Submit'])){ $user = mysql_real_escape_string($_POST['username']); //the pass is md5'd into the db so this one can only match if we md5 it do $pass = md5($_POST['password']); //make sure we stay secure $pass = mysql_real_escape_string($pass); //Look for the exact username and password in the db $sql = "SELECT * FROM tbl_users WHERE username = '$user' AND password = '$pass'"; $result = mysql_query($sql) or die (mysql_error()); $row = mysql_num_rows($result); //The if statment says if it finds a result (so more then 0 results) then continue if ($row != 0){ $_SESSION['user'] = $user; header("Location: index.php"); ?> perhaps you could show us the complete code that the login form is in, and the complete code from were the sessions are set?
-
ok, try doing it with option 2 and reply with what happens
-
This is correct $_SESSION['s_username'] = $username; When u entered this how did u enter it??: <?php //option 1 $username = $_SESSION["s_username"]; //option 2 $username = $_SESSION['s_username']; ?>
-
Could i see your file that the browser gets redirected to after clicking your submit button on your login form?
-
Do you have a login form???
-
can we see the file were : $_SESSION["Username"]; is set??
-
So i was just adding one last feature to a website - light window (its forums are currently unavalible ) so anyway im triyng to make it so my code only displays X amount of pics per line which worked untill i added this lightbox crap. Any ideas on how to now make everything appear on the same line?? (error can be seen at: http://www.schoolworkanswers.com/pictures.php?p=1) <?php if (isset ($_GET['p'])){ $page = $_GET['p']; }else{ $page = 1; } $itemPerPage = 12; $offset = ($page - 1) * $itemPerPage; $sql = "SELECT * FROM tbl_pic ORDER BY id DESC LIMIT $offset, 12"; $sql2 = "SELECT * FROM tbl_pic"; $result = mysql_query($sql) or die (mysql_error()); $result2 = mysql_query($sql2) or die (mysql_error()); $num = mysql_num_rows($result2); echo "<tr>"; $cols = 3; // number of columns here $count = 1; $rows = 0; //lets show the images as we find them while ($row = mysql_fetch_array($result)){ extract($row); //when the remainder of count divided by cols is 0 do the following.... if ($count % $cols == 0) { echo "</tr>"; // or close a tr and open a new one, etc.. echo "<tr>"; } $simg = str_replace("../","",$spath); $img = str_replace("../","",$path); echo "<a href=$img class=lightwindow title=ADD author=Kaon caption=$info><img src= $simg border =0></a>"; $count++; } echo "</table>"; ?>
-
I got a peice of code (result ccan be seen at http://schoolworkanswers.com/kaon/products.php?a=Sofas) and its suposed to subtract from a string till its 20 chars long then add ... at the end, so i tried using substr to 3 to test that and thats not working either idk what to do any idaes?? $cols = 5; // number of columns here $count = 1; $rows = 0; while ($row = mysql_fetch_array($result)){ extract($row); if ($count % $cols == 0) { echo "</tr>"; // or close a tr and open a new one, etc.. echo "<tr>"; $count++; $rows++; } $img = str_replace("../","",$th_path); $pdname = $pd_name; if(strlen($pd_name > 3)){ $pdname = substr($pdname,0,20); $pdname = $pdname . "..."; } echo "<td aling = center><img src=$img alt=''><br>$pdname</td></td>"; } } ?>
-
whats this line do?? $count % $cols == 0) never seen % used before
-
I have had a problem now for a while i tried playing around with the code and failed, i posted code on her and failed, so now im trying to ask how you would go about doing this and mabey i can get ideas. Im sql'ing my database to get image locations and then i want to post X amount of pictures on a line and have it go down a line everytime the number X is reached. Is that clear enough - if not ask questions
-
i do include the functions.php file, its just now showen in the code. and yes the error message is "Invalid username or password"
-
Im going to include two peices of code the function file code, and the code with the form and the code calling the function. My problem is everyone i call the function it returns the error message but im using the right login information. login.php: <?php if (isset($_POST['Submit'])){ $error = login(); if (isset($error)){ echo '<table width="397" height="113" border="0" align="center" cellpadding="0" cellspacing="0">'; echo"<tr><td>$error</td></tr>"; echo "</table>"; } } ?> <table width="397" height="113" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><form name="form1" method="post" action="login.php"> <label> Username: <input type="text" name="username" title="username:"id="username"> </label></tr></td> <tr><td> <label> Password: <input type="password" name="password" id="password"> </label> </tr></td> <tr><td> <label> <input type="submit" name="Submit" id="Submit" align="right" value="Submit"> </form> </label> </td> </tr> </table> Functions.php: <?php include ("connect.php"); error_reporting(E_ALL); function login(){ $user = $_POST['username']; $pass = $_POST['password']; $sql = "SELECT * FROM tbl_users WHERE username = '$user' AND password = '$pass'"; $result = mysql_query($sql) or die (mysql_error()); $row = mysql_num_rows($result); if ($row == 1){ $_SESSION['user'] = $user; }else{ $error = "Error Invalid username or password"; return $error; } } ?> anyone know why i keep getting this error message?
-
Need help making things not all display on one line
mike12255 replied to mike12255's topic in PHP Coding Help
im getting my db table (http://schoolworkanswers.com/kaon/products.php?a=Sofas) idk what could is producing that though because i edited it:(also not sure if putting this in a loop would do what i want, their are more then 4 fields in the db $sql = "SELECT * from tbl_product WHERE cat_name = '$area' ORDER BY pd_id DESC LIMIT $page, 14"; $row = 0; $result = mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_array($result)){ extract($row); echo " <p><center><h4>Your result(s):</center></h4>"; echo "<align='center'><table border=0 bgcolor='' >"; echo "<tr bgcolor='#FFFFFF' >"; for($i=0;$i<mysql_num_fields($result);$i++) { } while($row=mysql_fetch_row($result)) { extract($row); echo "<tr bgcolor='#FFFFFF'>"; for($j=0;$j<$i;$j++) { echo "<td>"; echo $th_path; echo "</td>"; } echo "</tr>"; } echo "</tr>"; echo "</table>"; } ?> -
I grabbing info from my db and throwing the info in a table, my problem is after 4 i need it to go down a row, but im not sure how to do this i've tried several things but cant get it, any ideas?? <table width="493" height="187" border="0" align="center"> <?php $sql = "SELECT * from tbl_product WHERE cat_name = '$area' ORDER BY pd_id DESC LIMIT $page, 14"; $i = 0; $row = 0; $result = mysql_query($sql) or die (mysql_error()); echo "<tr>"; while ($row = mysql_fetch_array($result)){ extract($row); /*if ($i ==4){ echo("<br>"); $row++; $i++; }*/ echo "<td align = \"center\">"; echo "<a href = \"item.php?id=$pd_id\"><img src=\"$th_path\" border=\"0\"><br>$pd_name</a>"; echo "</td>"; $i++; } echo "</tr>";?> </table></td> </tr>
-
So im designing a small kind of CMS for a client and i have a function created so they can modify a current product, but if they upload a new image the new image has to be resized and what not, so im trying to check for that and if that needs done, do it then update the database with the information, but if it dosn't need done, then leave it and update all the other information. However it seems my statment cleared everything in the row except for th_name any ideas?? <?php include ("connect.php"); if(isset($_GET['id']) && !is_numeric($_GET['id'])){ die('Forbidden'); } $id = (int) $_GET['id']; $sql = "SELECT * FROM tbl_product WHERE pd_id = $id"; $result = mysql_query($sql) or die (mysql_error()); $row = mysql_fetch_array($result); extract($row); ?> <html> <head> <title>Kaon Furniture Canada!</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <style type="text/css"> <!-- body,td,th { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #333333; } body { background-color: #FFFFFF; background-image: url(background.gif); background-repeat: repeat-x; margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } --> </style> <script type="text/javascript"> <!-- function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> </head> <body onLoad="MM_preloadImages('images/rollover_03.gif','images/rollover_04.gif','images/rollover_05.gif','images/rollover_06.gif','images/rollover_07.gif')"> <!-- ImageReady Slices (index.psd) --> <table width="800" height="570" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01"> <tr> <td colspan="9"> <img src="images/index_01.gif" width="800" height="13" alt=""></td> </tr> <tr> <td rowspan="4"> <img src="images/index_02.gif" width="11" height="142" alt=""></td> <td colspan="2"><a href="index.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image19','','images/rollover_03.gif',1)"><img src="images/index_03.gif" name="Image19" width="155" height="38" border="0"></a></td> <td colspan="2"><a href="aboutus.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image20','','images/rollover_04.gif',1)"><img src="images/index_04.gif" name="Image20" width="156" height="38" border="0"></a></td> <td><a href="products.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image21','','images/rollover_05.gif',1)"><img src="images/index_05.gif" name="Image21" width="155" height="38" border="0"></a></td> <td><a href="pictures.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image22','','images/rollover_06.gif',1)"><img src="images/index_06.gif" name="Image22" width="156" height="38" border="0"></a></td> <td><a href="contactus.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image23','','images/rollover_07.gif',1)"><img src="images/index_07.gif" name="Image23" width="155" height="38" border="0"></a></td> <td rowspan="4"> <img src="images/index_08.gif" width="12" height="142" alt=""></td> </tr> <tr> <td colspan="7"> <img src="images/index_09.gif" width="777" height="18" alt=""></td> </tr> <tr><?php if(isset($_POST['submit'])){ $id =$_GET['id']; $path = $_POST['file']; $cat = $_POST['catagory']; $desc = $_POST['desc']; $name =$_POST['name']; $sql = "SELECT * FROM tbl_product WHERE pd_id = $id"; $result = mysql_query($sql) or die (mysql_error()); $row = mysql_fetch_array($result); extract($row); if ($path != $pd_path){ $idir = "images/"; // Path To Images Directory $tdir = "images/thumbs/"; // Path To Thumbnails Directory $twidth = "125"; // Maximum Width For Thumbnail Images $theight = "84"; // Maximum Height For Thumbnail Images $url = $_FILES['imagefile']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['imagefile']['type'] == "image/jpg" || $_FILES['imagefile']['type'] == "image/jpeg" || $_FILES['imagefile']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['imagefile']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['imagefile']['tmp_name'], "$idir" . $_FILES['imagefile']['name']); // Move Image From Temporary Location To Permanent Location $path = "$idir" . $_FILES['imagefile']['name']; $name = $_POST['name']; $desc = $_POST['desc']; $area = $_POST['catagory']; $thpath = "$tdir" . $_FILES['imagefile']['name']; $query = "UPDATE tbl_product SET pd_name = '$name', pd_path = '$path', pd_desc = '$desc', cat_name = '$cat_name', th_path = '$thpath' WHERE pd_id = $id"; mysql_query($query) or die (mysql_error()); if ($copy) { // If The Script Was Able To Copy The Image To It's Permanent Location // print 'Image uploaded successfully.<br />'; // Was Able To Successfully Upload Image $simg = imagecreatefromjpeg("$idir" . $url); // Make A New Temporary Image To Create The Thumbanil From $currwidth = imagesx($simg); // Current Image Width $currheight = imagesy($simg); // Current Image Height if ($currheight > $currwidth) { // If Height Is Greater Than Width $zoom = $twidth / $currheight; // Length Ratio For Width $newheight = 100; // Height Is Equal To Max Height $newwidth = 150; // Creates The New Width } else { // Otherwise, Assume Width Is Greater Than Height (Will Produce Same Result If Width Is Equal To Height) $zoom = $twidth / $currwidth; // Length Ratio For Height $newwidth = 150; // Width Is Equal To Max Width $newheight = 100; // Creates The New Height } $dimg = imagecreate($newwidth, $newheight); // Make New Image For Thumbnail imagetruecolortopalette($simg, false, 256); // Create New Color Pallete $palsize = ImageColorsTotal($simg); for ($i = 0; $i < $palsize; $i++) { // Counting Colors In The Image $colors = ImageColorsForIndex($simg, $i); // Number Of Colors Used ImageColorAllocate($dimg, $colors['red'], $colors['green'], $colors['blue']); // Tell The Server What Colors This Image Will Use } imagecopyresized($dimg, $simg, 0, 0, 0, 0, $newwidth, $newheight, $currwidth, $currheight); // Copy Resized Image To The New Image (So We Can Save It) imagejpeg($dimg, "$tdir" . $url); // Saving The Image imagedestroy($simg); // Destroying The Temporary Image imagedestroy($dimg); // Destroying The Other Temporary Image header ("Location: productlist.php"); } else { print '<font color="#FF0000">ERROR: Unable to upload image.</font>'; // Error Message If Upload Failed } } else { print '<font color="#FF0000">ERROR: Wrong filetype (has to be a .jpg or .jpeg. Yours is '; // Error Message If Filetype Is Wrong print $file_ext; // Show The Invalid File's Extention print '.</font>'; } } }else{ $query = "UPDATE tbl_product SET pd_name = '$name', pd_path = '$path', pd_desc = '$desc', cat_name = '$cat_name' WHERE pd_id = $id"; mysql_query($query) or die (mysql_error()); header("Location: productlist.php"); } ?> <td rowspan="2"> <img src="images/index_10.gif" width="7" height="86" alt=""></td> <td colspan="2"> <img src="images/index_11.gif" width="152" height="62" alt=""></td> <td colspan="4" rowspan="2"> <img src="images/index_12.gif" width="618" height="86" alt=""></td> </tr> <tr> <td colspan="2"> <img src="images/index_13.gif" width="152" height="24" alt=""></td> </tr> <tr> <td height="400" colspan="9" valign="top" background="images/index_14.gif"><blockquote> <table width="366" height="339" border="0"> <tr> <td><table width="480" border="0"> <tr> <td>Name:</td> </tr> <tr> <td><form name="form1" enctype="multipart/form-data" method="post" action="modify.php?id=<?=$id?>"> <label> <input type="text" name="name" id="name" value = "<?=$pd_name?>"> </label> </form></td> </tr> <tr> <td>Description:</td> </tr> <tr> <td><label> <textarea name="desc" id="desc" cols="45" rows="5" ><?=$pd_desc?></textarea> </label> </form></td> </tr> <tr> <td>Catagory:</td> </tr> <tr> <td><select name="catagory" id="catagory" value = "<?= $cat_name?>"> <option>Sofas</option> <option>Beds and Bunks</option> <option>Dressers and Cabinets</option> <option>Side Tables and Desks</option> </select> </td> </tr> <tr> <td>Picture:</td> </tr> <tr> <td><img src="<?=$th_path?>" alt=""></td> </tr> <tr> <td> <label> <input type="file" name="file" id="file" value="$pd_path"> </label> </form></td> </tr> <tr> <td><label> <input type="submit" name="submit" id="submit" value="Submit"> </label> </form></td> </tr> </table> <?php ?></td> </tr> </table> <p> </p> <p> </p> </blockquote> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <blockquote> <p> </p> </blockquote> <p> </p> <p> </p></td> </tr> <tr> <td colspan="9"> <img src="images/index_15.gif" width="800" height="78" alt=""></td> </tr> <tr> <td> <img src="images/spacer.gif" width="11" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="7" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="148" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="4" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="152" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="155" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="156" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="155" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="12" height="1" alt=""></td> </tr> </table> <!-- End ImageReady Slices --> </body> </html>
-
<textarea name="desc" id="desc" cols="45" rows="5" ><?=$pd_desc?></textarea> just enter the information after first closing arrorw as above, found out myself.
-
[SOLVED] Unknown column '38' in 'where clause'
mike12255 replied to mike12255's topic in PHP Coding Help
no its this stupied ftp program shut down computer restarted opened it up reuploaded file and it worked - never use Core FTP -
[SOLVED] Unknown column '38' in 'where clause'
mike12255 replied to mike12255's topic in PHP Coding Help
This is going to sound really messed up but i entered your code i know i uploaded the right file after saving i know im looking at the right file, and i still got the same error.