A database for my data

From: Peter (BOUGHTONP)13 Dec 2008 23:40
To: Ally 82 of 158
Hmmm... actually you're right - should have done a form with method=get instead of the onclick stuff; I was just 'fixing' what was there, rather than thinking properly. :(
From: Ally13 Dec 2008 23:48
To: Peter (BOUGHTONP) 83 of 158
Meh, it rarely matters in situations like this one. BUT YES YOU SHOULD HAVE B-)
From: ANT_THOMAS13 Dec 2008 23:55
To: Ally 84 of 158
I can't believe he's been fobbing me off with poorly thought out code :((
From: Peter (BOUGHTONP)13 Dec 2008 23:57
To: Ally 85 of 158
It always matters. :( An undisciplined mind leads to sloppy thinking, which leads to inefficiency and results in not having a new personal website for half a decade. :((
From: Peter (BOUGHTONP)14 Dec 2008 00:01
To: ANT_THOMAS 86 of 158
Please accept my humble apologies. :$


Here is what I should have given you:
HTML code:
<form action="./fullc.php" method="get">
	<input type="text" name="code" value="AT"/>
	<button type="submit">Go To</button>
</form>
From: ANT_THOMAS14 Dec 2008 00:09
To: Peter (BOUGHTONP) 87 of 158

(hug)

 

I might just keep the original code :P

 

Anyway, what makes this "better"?

From: Peter (BOUGHTONP)14 Dec 2008 00:23
To: ANT_THOMAS 88 of 158
Because it's the right way. :{)

Um, specific things... primarily, it's easier to read (you know where you're going from the start) and more maintainable (if you wanted to add further fields, you just add the input tag - no need to change the onclick), and also it doesn't rely on JavaScript when it doesn't need to (simple things are less likely to break).

For a smallish internal app like this, the benefits are only slight, but when you get to larger apps, they become more significant. As I said, it's good to keep in the right frame of mind.
From: ANT_THOMAS10 Feb 2009 00:03
To: ALL89 of 158
PHP code:
$editnews =MYSQL_QUERY("UPDATE nmr SET code='$code',labbookref='$labbookref',contents='$contents',solvent='$solvent',elements='$elements',servercode='$servercode',time='$time',machine='$machine',year='$year',month='$month',nmre1='$nmre1',nmrn1='$nmrn1',nmre2='$nmre2',nmrn2='$nmrn2',nmre3='$nmre3',nmrn3='$nmrn3',nmre4='$nmre4',nmrn4='$nmrn4',nmre5='$nmre5',nmrn5='$nmrn5' WHERE id='$id' ");
 


What's wrong with this?

It's pulling the data from a form but doesn't actually update the entry, doesn't chuck out an error either.
EDITED: 10 Feb 2009 00:05 by ANT_THOMAS
From: Peter (BOUGHTONP)10 Feb 2009 00:11
To: ANT_THOMAS 90 of 158
Echo the statement and try running it directly in mysql - you might see/get an error then?

Is Id a varchar or integer?
From: ANT_THOMAS10 Feb 2009 00:18
To: Peter (BOUGHTONP) 91 of 158

Id is mediumint(5).

 

Just tried echoing it and it doesn't seem to echo $id which is odd.

 

Actually, I may know why.

From: ANT_THOMAS10 Feb 2009 00:23
To: ALL92 of 158

Right, id issue sorted, when I echo it and run it directly in mysql (phpmyadmin) it works fine, no errors, and the database updates as expected.

 

:@

From: ANT_THOMAS10 Feb 2009 00:25
To: ALL93 of 158
Ok, it's working now, seems it was my id issue. Yay, done.
From: Peter (BOUGHTONP)10 Feb 2009 00:27
To: ANT_THOMAS 94 of 158
You probably want something like:
code:
if ( ! isNumeric($id) ){ throwError('Invalid id supplied'); }


Just before the query.

That way, next time you have null/blank/other in Id you don't get an apparent success whilst nothing actually happens... :)
From: ANT_THOMAS10 Feb 2009 01:43
To: ALL95 of 158

Since it's all to do with the same database/site I'll ask it in this thread.

 

Is it possible to have a link/button on a website that tells the server to execute a batch file of some sort?

 

For my site I use Irfanview to convert PDFs to PNGs which are dumped in a certain folder, and I do this manually. After looking around it seems that you can run Irfanview from the command line with whatever switches you want, I'll have to look into what exactly I need, but only if it's worth doing.

From: Drew (X3N0PH0N)10 Feb 2009 02:16
To: ANT_THOMAS 96 of 158
http://uk2.php.net/manual/en/function.exec.php

Not sure it whether works on windows.
From: THERE IS NO GOD BUT (RENDLE)10 Feb 2009 18:52
To: ANT_THOMAS 97 of 158
If you're wanting to do image conversion, take a look at ImageMagick, for which there is a PHP PECL package.
From: ANT_THOMAS16 Feb 2009 22:16
To: THERE IS NO GOD BUT (RENDLE) 98 of 158
I shall take a look at that some point soon!
From: ANT_THOMAS16 Feb 2009 22:35
To: ALL99 of 158
Right, I have this code:

PHP code:
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ $prefixweb = "./nmr/{$row['machine']}/{$row['year']}/{$row['month']}/data/AB/nmr/{$row['servercode']}/";
    $prefixuni = "file:///N:/vol3/users/snmrdata/{$row['machine']}/{$row['year']}/{$row['month']}/data/AB/nmr/{$row['servercode']}/";
 
    echo " STUFF ";
}


I want to make it so when "machine" ({$row['machine']}) is a certain specific value, the value being "varian", the directory structures of $prefixweb and $prefixuni change.

If I'm thinking right I need to use an if else statement.

I've tried and failed as usual, hence the post.

I've concentrated on only one of the directory structures, $prefixuni, since that's the one I use the most.

So yeah, I've got this:

PHP code:
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{$prefixweb = "./nmr/{$row['machine']}/{$row['year']}/{$row['month']}/data/AB/nmr/{$row['servercode']}/";
 
if ($row['machine']=="varian")
{ 
$prefixuni = "file:///N:/vol3/users/snmrdata/{$row['year']}/service/{$row['month']}/4_StuYEAR/{$row['servercode']}/"
 
else 
 
$prefixuni = "file:///N:/vol3/users/snmrdata/{$row['machine']}/{$row['year']}/{$row['month']}/data/AB/nmr/{$row['servercode']}";
}
    echo " STUFF ";
}


It don't work, why? :C


Also, can you have it try for a few different specifics then to go to a default?

As in

If A then 1 or
if B then 2 or
if C then 3
else 4
From: steve16 Feb 2009 22:48
To: ANT_THOMAS 100 of 158
if (uh) {
something
}
else
{
something else
}

You have missed the closing }'s. Although that might not be the problem, as you've not mentioned the very obvious error that would come with that?

That might not even be PHP. I am late to thi thread. :C
From: ANT_THOMAS16 Feb 2009 22:55
To: steve 101 of 158
code:
Parse error: syntax error, unexpected T_ELSE in C:\wamp\www\full-iftest.php on line 41


After adding a } it still doesn't like it. Clearly has an issue with the else statement.