Jump to content

Poddy

Members
  • Posts

    29
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Poddy's Achievements

Member

Member (2/5)

0

Reputation

  1. You have incorrect syntex in your insert query it should be insert into table (colmuns) values (data)
  2. Try using the while loop alone maybe it dosent catch the result on the first loop and prints blank as in while ($row=mysql_fetch_assoc($rs)) { commands } sorry about formatting typing from a cellphone
  3. Dont save the full path in mysql use relative paths as in your example use pics/name.jpg if you want an image from a dirctory 1 level up from your files use ../name.jpg
  4. I had the same problem a while ago try using <pre> tag around the output it fixed it for me
  5. well i solved the first issue... using the BETWEEN statement and correcting the date format which for some reason i remembered it as a diffrent format.. my mistake. However i still can't figure out how to SUB a date and ADD a date with days i have tried this in the mssql console yet still not working SELECT * FROM data WHERE timestamp BETWEEN dateadd(day, -6, '2008-01-08') AND '2008-03-08' AND name LIKE '$name' AND spot LIKE '$line' AND piret LIKE '$piret' ORDER BY timestamp DESC
  6. Hello all, I'm having a problem with converting a script from MySQL to MSSQL .. the problem is within this query: select * from data where name LIKE '$name' AND spot LIKE '$line' AND piret LIKE '$piret' [b]AND timestamp >= '$before' AND timestamp <= '$after' ORDER BY timestamp DESC[/b] the statement works until the bold part... please note that all the variables except $before and $after are inserted with a '%'. and before and after are built like this: 08/01/2008 i need it to select from dates between lets say 08/01/2008 and 08/03/2008 including those dates so records from the 1st, the 2nd and the 3rd will appear.. however i cannot get it to work is there another way of making this statement? the query does not fail, but does not return results. also i have another issue: SELECT * FROM data WHERE timestamp >= DATE_SUB(curdate(), INTERVAL 5 DAY) AND timestamp <= DATE_ADD(curdate(), INTERVAL 1 day) AND name LIKE '$name' AND spot LIKE '$line' AND piret LIKE '$piret' ORDER BY timestamp DESC " i have this old line of code, but i cant find a function that works for me for current time, and subtract and add days that belong to mssql.. the function of that script is PHP recognizing the day of the week and the script chooses records of that week only. Any help appriciated Thanks in advance ???
  7. thanks for the replys, but one thing i still do not understand, i need to select the CURRENT week so if i replace your_date with CURDATE it would just input the same result.. how will that work... what am i supposed to put in "your_date"
  8. i want my results to show only from the current week as in sunday to sunday... is this possible? thanks in advance
  9. Solved, changed the column to DATE type and added insertion of date in the insert query, which i tried to avoid.. works well now thanks everyone
  10. thanks for the reply but it still dosent display the last day query: select * from `data` WHERE `timestamp` >= '2008-06-15' AND `timestamp` <= '2008-06-25' ORDER BY `timestamp` DESC result: Edit Delete 101 4 fghf 456 fghfg 1 2008-06-24 17:09:10 5 5 5 Edit Delete 96 5 sdfds 324 dfgdf 1 2008-06-15 17:08:12 5 5 5
  11. i have this code: $sql = "select * from `data` where `name` LIKE '$name' AND `spot` LIKE '$line' AND `piret` LIKE '$piret' AND `timestamp` BETWEEN '$before' AND '$after' ORDER BY `timestamp` DESC "; it works fine, the problem is if i select from dates like 2008-06-11 to 2008-06-25 i get all dates between them, but those with 25 i do not get.. is there any way to get around this? thanks
  12. they were being assigned from a form, as i knew that part was fine i left it alone anyway, thanks for your help for some reason replacing $varshort[] = "'$" . $row['short'] . "'"; in $varshort[] = $$row['short']; fixed the problem, as it was getting the variable name, and not the content. thank you very much, you both
  13. I am trying to get a dynamic form(one which you can add questions into) to post the dynamic questions, it fetches the questions from a questions database then inserts it into the form. however on the processing of the form when i try inserting into the database all i get is 0 0 0 when the result is supposed to be 5 5 5 the post variables are working since i echoed them.. the problem seems to be with the query yet it does do the insert query but with the wrong data <?php $sql = "select `short` from `questions`"; $result = mysql_query($sql) or die ('error 43' . mysql_error()); while ($row = mysql_fetch_assoc($result)) { $short[] = $row['short']; $varshort[] = "'$" . $row['short'] . "'"; } $fields = implode(',',$short); echo $fields . "<br /> "; $values = implode(',',$varshort); echo $values; $sql = "insert into `data` (name, spot, piret, text, $fields) VALUES ('$name', '$spot', '$piret', '$text', $values )"; mysql_query($sql) or die ('ERROR' . mysql_error()); ?>
  14. had a couple of $result variables redefining inside the loops.. just had to change their names topic solved
  15. i have the following code: if ($bd == null) { $sql = "select * from `data` where `name` LIKE '$name' AND `spot` LIKE '$line' AND `piret` LIKE '$piret' "; $result = mysql_query($sql) or die ('blah balh' . mysql_error()); $numrows = mysql_num_rows($result); while ($row = mysql_fetch_assoc($result)) { $timestamp = $row['timestamp']; $line = $row['spot']; $piret = $row['piret']; $name = $row['name']; $comment = $row['text']; /* $takeoff = $row['takeoff']; $cockpit = $row['cockpit']; $appear = $row['appear']; $take += $takeoff; $cock += $cockpit; $appe += $appear; */ echo " <table width='200' border='1'> <tr> <td> $timestamp </td> <td> $name </td> </tr> <tr> <td rowspan='2'> $comment </td> <td> פירט: $piret </td> </tr> <tr> <td> ליין: $line </td> </tr>"; $sql = "select `short` from `questions`"; $result = mysql_query($sql) or die ('error' . mysql_error()); while ($row = mysql_fetch_assoc($result)) { $short = $row['short']; qvalues($short); } echo " </table> "; } } function code: function qvalues ($var) { $sql = "SELECT * FROM `data` where `$var` LIKE '%'"; $result = mysql_query($sql) or die ('error' . mysql_error()); $row = mysql_fetch_assoc($result); $points = $row["$var"]; $sql = "select `text` FROM `questions` where `short`='$var'"; $result = mysql_query($sql) or die ('error' . mysql_error()); $row = mysql_fetch_assoc($result); $text = $row['text']; echo "<tr><td> $points </td> <td> $text </td></tr>"; } this code generates a table with a name, timestamp, comment, piret and spot aswell as the score points this worked fine until now, but i needed to be able to add dynamically questions to the database so the table needed to be a bit more dynamic as well, i created the function to retrieve the data i need... it works however as of the change for the function the while($row = mysql_fetch_assoc($result)) only shows me 1 table, aka giving the script only 1 row... any help is appreciated
×
×
  • 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.