CodingA database for my data

 

Press Ctrl+Enter to quickly submit your post
Quick Reply  
 
 
  
 From:  ANT_THOMAS   
 To:  Peter (BOUGHTONP)     
35356.70 In reply to 35356.69 

Right. Quoting made it work. Thanks.

 

I still need to sort out protecting my database.

 

I may just password protect the site (fail)


0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  ANT_THOMAS      
35356.71 In reply to 35356.70 
quote:
I may just password protect the site

Depends how much you trust the rest of your group/etc?


Even if you trust them absolutely, I'd still getting into the habit of parametrising queries.

(Not sure about PHP, but with CFML the param-ing queries can further help performance as well, since it can cache one query execution plan for many queries, which is often more efficient.)



Oh, and whilst I'm thinking about it... since this is important data, you are backing up your database, right?

(Can be as simple as an automated mysqldump then zip the output and move somewhere.)
0/0
 Reply   Quote More 

 From:  ANT_THOMAS   
 To:  Peter (BOUGHTONP)     
35356.72 In reply to 35356.71 

Aye. I've been taking a backup every so often. But automated would be far more useful.

 

I also handwrite each entry in my lab book :D


0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  ANT_THOMAS      
35356.73 In reply to 35356.72 
Well there's an assortment of examples you could use on the mysqldump manual page:
http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html

Some of them rather complex, but there's some simple ones there too.
0/0
 Reply   Quote More 

 From:  ANT_THOMAS   
 To:  Peter (BOUGHTONP)     
35356.74 In reply to 35356.73 
Ok! I shall have a look at that. Thanks again.

Another question (yay) :

I want an input box where I can stick my 'code' (AT052 etc), click "Go to entry" and it takes me to fullc.php?='AT052'. This one I assume is painfully easy and really does show my lack of knowledge, or more so, what to search since I've been searching lots.

Found plenty of form code for sticking a URL in a box and going to it but I want to stick part of the URL in a box.

Ended up with this:
HTML code:
<form name="openlocation">
<input type="text" name="code" value="AT">
<input type="button" value="Go To" onClick="document.location = "fullc.php?="'document.openlocation.code.value';; ">
</form>

(Which clearly doesn't work)

0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  ANT_THOMAS      
35356.75 In reply to 35356.74 
I think you've got jQuery up and running? If so, you can do:
HTML code:
<input type="text" id="code" value="AT"/>
<button type="button" onclick="location.href='./fullc.php?code='+$j('#code').val();">Go To</button>



If not, it's slightly longer but not too bad:
HTML code:
<input type="text" id="code" value="AT"/>
<button type="button" onclick="location.href='./fullc.php?code='+document.getElementById('code').value;">Go To</button>
0/0
 Reply   Quote More 

 From:  ANT_THOMAS   
 To:  Peter (BOUGHTONP)     
35356.76 In reply to 35356.75 

Yay, nearly there. Just the 'code' needs to be in single quotes in the final URL.

 

Though that now seems to have broken somehow :@


0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  ANT_THOMAS      
35356.77 In reply to 35356.76 
No no no no no - put the single quotes around the variable in the SQL query, not inside the code variable itself!

Otherwise you're just making things much more complicated for yourself.
0/0
 Reply   Quote More 

 From:  ANT_THOMAS   
 To:  Peter (BOUGHTONP)     
35356.78 In reply to 35356.77 

Fantastic. Done. Sorted. Working. :D

 

Also, don't worry, I'll be keeping you occupied with more questions in the coming weeks/months. :Y


0/0
 Reply   Quote More 

 From:  Ally  
 To:  Peter (BOUGHTONP)     
35356.79 In reply to 35356.75 
You do terrible things with HTML tags :-((
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  Ally     
35356.80 In reply to 35356.79 
If by "terrible things" you mean use them properly as intended, then yes.
0/0
 Reply   Quote More 

 From:  Ally  
 To:  Peter (BOUGHTONP)     
35356.81 In reply to 35356.80 
Well, not really. In this case it's just an internal project and it clearly doesn't matter and I'm just being pedantic. But a button with an onclick to change URLs is horrible.
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  Ally     
35356.82 In reply to 35356.81 
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. :(
0/0
 Reply   Quote More 

 From:  Ally  
 To:  Peter (BOUGHTONP)     
35356.83 In reply to 35356.82 
Meh, it rarely matters in situations like this one. BUT YES YOU SHOULD HAVE B-)
0/0
 Reply   Quote More 

 From:  ANT_THOMAS   
 To:  Ally     
35356.84 In reply to 35356.83 
I can't believe he's been fobbing me off with poorly thought out code :((

0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  Ally     
35356.85 In reply to 35356.83 
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. :((
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  ANT_THOMAS      
35356.86 In reply to 35356.84 
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>
0/0
 Reply   Quote More 

 From:  ANT_THOMAS   
 To:  Peter (BOUGHTONP)     
35356.87 In reply to 35356.86 

(hug)

 

I might just keep the original code :P

 

Anyway, what makes this "better"?


0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  ANT_THOMAS      
35356.88 In reply to 35356.87 
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.
0/0
 Reply   Quote More 

 From:  ANT_THOMAS   
 To:  ALL
35356.89 
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.

0/0
 Reply   Quote More 

Reply to All  
 

1–20  21–40  41–60  61–80  81–100  …  141–158

Rate my interest:

Adjust text size : Smaller 10 Larger

Beehive Forum 1.5.2 |  FAQ |  Docs |  Support |  Donate! ©2002 - 2024 Project Beehive Forum

Forum Stats