Jump to content

chipmunken

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

chipmunken's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok I want to make a quarry that get's data from current date and X days back in time. This is because I want to extract today's stats and compare them with previous days. This is what I got so far. SELECT * FROM `sla_gen` WHERE transaction_date BETWEEN CURDATE() AND DATE_SUB(CURDATE(), INTERVAL 5 DAY) I have fiddled around with ADDDATE() and some other functions but I'm totally lost. I don't even know if I'm on the right track here. A pointer in the right direction is much appreciated.
  2. SELinux? or what firewall is being used?
  3. Ok Im trying too make this shell script create users from my text file, I also want to type in a password that will be set to the users. #!/bin/sh # Sebastian schmidt clear echo "This script creates accounts for the people you have listed in the file (users) and puts them in the group it." echo "" echo "given and surname must be seperated with ( in the file (users)." echo "If you want to execute the script now type (yes) and press enter, else type exit and press enter." id | grep root 2>/dev/null >/dev/null if [ $? -eq 1 ] then echo "You need to be root before running this script." echo "Please restart this script as root and all will be fine." exit fi read svar if [ "$svar" = "yes" ] then echo "Type password for the new users." read pass echo "Type in the path for the file (users)" #echo $pass read users groupadd it 2>/dev/null >/dev/null for i in `sed 's/\(..\).*@\(..\).*/\1\2/' $users` do useradd -g it -p $pass -s /bin/bash -m -d /home/it09$i it09$i 2>/dev/null >/dev/null done echo "Done!" elif ["$svar" = "exit"] then echo "exiting script" exit fi This is how my textfile looks like sebastian@schmidt sandra@fahlen tomas@persson All works fine when it comes to createing the users and home catalogs. The problem is the password wont stick.. I dont know whats wrong. When I switch to a normal user and try to su to one of the created users it asks me for a password and then it says Help wanted
  4. Ok now I have found the problem. It was with the _GET function that dident fetch the &sub=3&info=54 from my address bar so my SQL query dident fetch anything. Now I just need to understnad why the $info=$_GET['info']; dont work in my iframe.
  5. Im stuck on this problem, a pointer in the right direction woulde be very thankful.
  6. Since I have an iframe inside my working php page cant I just _POST the variabel and then print it? Ill do some testing on this matter.. Or is there something I dont know when working with iframes in php?
  7. Ok here is the deal. I have built an product catalog and everything works fine untill I decided to implement an iframe where the product specifications are. First I hade all code on same page and it all worked fine. Then I migrated the print code to the iframe and I get errors. Here is my main catalog page that works. print nl2br (mysql_result($result_info, "info")); This line works here but not in the iframe ??? I have put the iframe and just below this line. <?php if (!defined('SECURITY')) { exit; } function katalog($items, $dir='') { $sub=$_GET['sub']; $info=$_GET['info']; // Fetches the catagories from the menu table $sqlmeny = "SELECT * FROM `meny` LIMIT 0 , 30"; $meny=mysql_query($sqlmeny); $countmeny=mysql_num_rows($meny); if ($info > 0){ // Fetches the product that is shown on the right side $sql_bild = "SELECT photo FROM `sbjbs_product_info` WHERE `id_contact` LIKE '$info' LIMIT 0 , 30"; $result_bild=mysql_query($sql_bild); $sql_product = "SELECT product FROM `sbjbs_product_info` WHERE `id_contact` LIKE '$info' LIMIT 0 , 30"; $result_product=mysql_query($sql_product); $sql_info = "SELECT info FROM `sbjbs_product_info` WHERE `id_contact` LIKE '$info' LIMIT 0 , 30"; $result_info=mysql_query($sql_info); } // Gets all product's that is going to be listed in the submenu $sql = "SELECT * FROM `sbjbs_product_info` WHERE `katigori` LIKE '$sub' LIMIT 0 , 30"; $result=mysql_query($sql); $count=mysql_num_rows($result); $pil1 = 'box_3-03.png'; $bg1 = ''; $text1 = '000000'; $pil2 = 'box_3-03_2.png'; $bg2 = ''; $text2 = '000000'; $pil3 = 'box_3-03.png'; $bg3 = ''; $text3 = '000000'; ?> <table width="560" border="0" cellpadding="0" cellspacing="0" class="box_4"> <tr> <td colspan="2" height="7"><img src="images/box_4/box4_01.png" alt="" /> </td> </tr> <tr> <td colspan="2" align="left" valign="top" class="box_4_content"> </td> </tr> <tr> <td width="257" align="left" valign="top" class="box_4_content_k"> <? // ******************************** START OF MENU LOOP ******************************** while($menyrows=mysql_fetch_array($meny)){ ?> <table border="0" cellpadding="0" cellspacing="0"> <td height="2"> </td> <td height="2" width="210"> <? if ($sub == $menyrows['id']){ echo '<img src="/images/box_13/liten/box13_01_w210.png" alt="" border="0">'; } ?> </td> <tr> <td valign="top"> <? if ($sub == $menyrows['id']){ echo '<img src="/images/box_3/' . $pil2 . '" alt="" height="9" width="9" border="0"> '; } else {echo '<img src="/images/box_3/' . $pil1 . '" alt="" height="9" width="9" border="0"> ';} ?> </td> <td width="210" <? if ($sub == $menyrows['id']){ echo 'class="kat2"'; } ?> > <a href="?lang=en&sec=products&sub=<? echo $menyrows['id']; ?>"> <div style="color:#<? echo $text1; ?>"> <? echo $menyrows['kat']; ?></div> </a> <? if ($sub == $menyrows['id']){ while($rows=mysql_fetch_array($result)){ ?> <div style="font-size:9px"> <a href="?lang=en&sec=products&sub=<? echo $sub; ?>&info=<? echo $rows['id_contact']; ?>" target="" alt="<? echo $rows['product']; ?>"><? echo $rows['product']; ?></a></div> <? } } ?> </td> </tr> <tr> <td height="13"> </td> <td <? if ($sub == $menyrows['id']){ echo 'class="kat3"'; } ?> height="13"> </td> </tr> </table> <? } //******************************** END OF LOOP ******************************** ?> </td> <td width="257" align="center" valign="middle" class="box_4_content_k"><table width="254" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="139" align="left"><? if ($info > 0){ ?> <div align="center" style="font-size:12px; font-size:larger;"><? print(mysql_result($result_product, "product")); ?> </div> <div align="center"><img src="system/images/product/<? print(mysql_result($result_bild, "photo")); ?>" alt="" width="92" /></div> <? } ?> </td> </tr> <tr> <td> <? if ($info > 0){?> <div align="left" style="font-size:12px;"> <? //******************* PROBLEM AREA ********************* // Here I used to print out the product info like this. // And it works fine. When I move this line into the iframe I get error. print nl2br (mysql_result($result_info, "info")); ?></div> <iframe name="product_iframe" id="product_iframe" frameborder="0" height="120" width="257" scrolling="auto" src="/sections/components/product_iframe.php"> </iframe> <? //******************* END OF PROBLEM AREA ********************* } ?></td> </tr> </table></td> </tr> <tr> <td colspan="2" height="43"> <img src="images/box_4/box4_03.png" alt="" /></td> </tr> </table> <?php } ?> Here is my iframe file with exact same line that dosent work ??? <?php include_once "myconnect.php"; $info=$_GET['info']; $sql_info = "SELECT info FROM `sbjbs_product_info` WHERE `id_contact` LIKE '$info' LIMIT 0 , 30"; $result_info=mysql_query($sql_info); echo '<div align="left" style="font-size:12px;">'; print nl2br (mysql_result($result_info, "info")); //print $result_info['info']; //while($svar=mysql_fetch_array($result_info)){ //echo $svar['result_info']; //print(mysql_fetch_assoc($result_info, "info")); // mysql_fetch_assoc echo '</div>'; ?> Here is my error Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in product_iframe.php on line 24
  8. Well then as i said in first post this script was taken from a site http://www.phpeasystep.com/mysql/10.html Thats why I wanted to see whats was wrong with it. I have another update databas structure on my site today that lists the posts and puts a update link next to each db post. When link is clicked you are directed to a new page with that specific entry where you edit and update. When I came accross this script I found it a little bit better for my purpose. Since you skip some steps and makes editing faster. Not really that important but when I get some time off Ill have to make my own one day
  9. here you go <?php $host="localhost"; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name="test"; // Database name $tbl_name="test_mysql"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); // Count table rows $count=mysql_num_rows($result); ?> <table width="500" border="0" cellspacing="1" cellpadding="0"> <form name="form1" method="post" action=""> <tr> <td> <table width="500" border="0" cellspacing="1" cellpadding="0"> <tr> <td align="center"><strong>Id</strong></td> <td align="center"><strong>Name</strong></td> <td align="center"><strong>Lastname</strong></td> <td align="center"><strong>Email</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center"><? $id[]=$rows['id']; ?><? echo $rows['id']; ?></td> <td align="center"><input name="name[]" type="text" id="name" value="<? echo $rows['name']; ?>"></td> <td align="center"><input name="lastname[]" type="text" id="lastname" value="<? echo $rows['lastname']; ?>"></td> <td align="center"><input name="email[]" type="text" id="email" value="<? echo $rows['email']; ?>"></td> </tr> <?php } ?> <tr> <td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </td> </tr> </form> </table> <?php // Check if button name "Submit" is active, do this if($Submit){ for($i=0;$i<$count;$i++){ $sql1="UPDATE $tbl_name SET name='$name[$i]', lastname='$lastname[$i]', email='$email[$i]' WHERE id='$id[$i]'"; $result1=mysql_query($sql1); } } if($result1){ header("location:update_multiple.php"); } mysql_close(); ?>
  10. I like the example from this site I found. I have used another example from this site and I hade to fix some stuff before it worked 100%. Now I want this update multiple row example becouse it fits my needs. It gets the data from my db and inserts it into the forms fields. I alter the fields and then press submit.. And the changes wont stick. Its back to as it was before...I have modifed the form and so on so it fits me. After fiddeling with it and not geting it to work I copied exactly as its done on the page and still dosent work. After looking at the code I think the problem is with the name's of the fields in the form. I dont know how the submit function work when you have a if($Submit). I think its cus the array isent changeing to the new values? Take a look at this example and please tell me whats wrong with it. http://www.phpeasystep.com/mysql/10.html Things I think might be wrong. form action="" ? Not needed when you have if(Submit)? id="name" this is the same on every loop should not thise be uniqe? id="lastname" id="email"
  11. Solved problem without CSS I knew it whoulde be possible with only php. I forgot about else haha Well here is the code that made it all happen. <? if ($sub == $menyrows['kat']){ echo '<img src="/images/box_3/' . $pil2 . '" alt="" border="0">'; } else {echo '<img src="/images/box_3/' . $pil1 . '" alt="" border="0">';} ?>
  12. Both of you suggest CSS but how to identify the link in css? Without changeing all of the images? When I click link[1] it send's a value in address field witch is uniqe. So I figure that if $sub == $menyrows['kat'] then change pic. You dont need to write the code but a more detailed explanation woulde be awsome. Or a link in the right direction link[1] link[2] link[3] I still need an if statment of some kind. It was all easy when I only hade 4 catagoris and the products under them was from databas. Now when the catagories also come from DB I cant get my head around identifying witch array value is clicked.
  13. Is this what you hade in mind? syntax not correct ofc its just a copy past model of what I think you ment. This is the best I can come up with at this hour. Kinda late so ill check if I understand it better tomorrow a { border:0; color:#555; text-decoration:none; background-image: url('something.gif'); background-repeat: no-repeat; background-attachment:fixed; background-position: 50px 100px; } a:activ{ color:#000; text-decoration:none; background-image: url('something_else.gif'); background-repeat: no-repeat; background-attachment:fixed; background-position: 50px 100px;
  14. I suggest to use the php xml DOM functions, start playing with the examples provided by the php manual
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.