limitphp
-
Posts
706 -
Joined
-
Last visited
Posts posted by limitphp
-
-
Thanks for the quick reply
bugger another language
I shall look into it and see if I can do all I want to do in it.
No, no no....thats what i thought too when the good people here told me I need to use ajax for what I wanted....
its nothing new...
its javascript and php working together.....
for some reason they call this process ajax...
actually, what it really is is just a new function in javascript....
this XMLHttpRequest
it allows javascript to call a page (even a php page) in the background without refreshing the current page (I might be off here, but I think thats what it is)....
and then most people use that with an ability that javascript has had for a good while....
the innerHTML
the ability to replace anything on the screen with new stuff.
-
Hi all, I am trying to acheive something in php, that I have tried searching this forum but nut quite sure what to search for!
Basically I have an index.php, and using .css this is displayed as a left sidebar and a main content. Basically what I want to do is; when a link is clicked in the left side bar, the main content should show the result. Ie, if the user has added his email address to his profile then when he clicks on say 'email address' on the left, the main contact page will show his email address without loading another page like indexuseremailaddress.php to display it.
Would I have to do something like split the sidebar into another php page called something like left.php and call the main content main.php and have them both display from index.php? Wouldnt this leave me with the same problem of having more than one main content page for each detail?
I hope this is clear enough!
Thanks
I think what you're describing will require ajax.
Read their tutorial example....
its easy to get started with this:
http://www.phpfreaks.com/forums/index.php/topic,115581.0.html
Basically, what you'll be doing is
when they click a link, the link will point to a javascript function that will make a call to a new page and display the contents of that new page in a div.
You'll have the main content in a div or something with an id of say "ajaxBox". And the javascript function will replace everything in that div with whatever you need.
-
I have a table
playlist_songs
columns include:
id, playlistID, songID
I want to select all the playlists that songID '1' is in and count the number of songs in each playlist. Is this possible with 1 query?
Right now I'm doing this:
SELECT COUNT( id )
FROM playlist_songs
WHERE songID = '1'
GROUP BY playlistID
But its giving me the wrong count for each playlist.
-
ok, now it works....
I had to change the order in the inner join:
SELECT p.name, count( ps.id ) AS song_count
FROM playlists p
INNER JOIN playlist_songs ps ON ps.playlistID = p.id
WHERE p.userID =2
GROUP BY p.name
-
I have two tables:
playlists
columns include:
id, name, userID
playlist_songs
columns include:
id, playlistID, songID
I want to list all the playlists for userID 2 and I want to show the number of songs in the playlist.
I tried using this query:
SELECT name,COUNT(ps.playlistID) as song_count
FROM playlists p
INNER JOIN playlist_songs ps ON p.id = ps.playlistID
WHERE userID = 'u2'
I get this error:
#1140 - Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
I tried putting a GROUP BY song_count in there, but that didn't work either.
Do I need to do something other than using an inner join to get the song count for each playlist?
thanks
-
If you have no cell spacing then just apply your borders to the bottom/right and remove the right border from the main table.
looks like that is what I had to do....
just thought maybe, they would let you declare the border: 1 px and that would take care of it without doubling up on adjacent borders, but I guess not.
I read somewhere that border-collapse would do it, but that didn't work in firefox.
-
this might sound too simple but can you not just write
table, tr, td { border: solid; }
I think that if you don't specify the px value it won't overlap?
Unfortunately that did not work. It made the borders really thick.
-
If I want to have borders in tables that are 1 px in width:
- if I put style='border: 1px solid' in the table tag, it'll just put a border around the whole table, but not individual cells.
- if I put style='border: 1 px solid" in the td tags, it'll give me a border for each individual cell, but it will double up where the cells meet. In other words, in between two cells it will have a border width of 2px.
Is there an easy way to get 1px borders for tables?
thanks
-
If I have a query:
$querySongs = "SELECT COUNT(songID)
FROM vote
WHERE songID = '$songID'";
$resultSongs = mysql_query($querySongs) or die (mysql_error());
$rowSongs = mysql_fetch_assoc($resultSongs);
How do I grab the COUNT(songID)?
like this:
$count = rowSongs[COUNT(songID)];
??
thanks....
by the way, whoevr wrote that tutorial on UNION JOINS thank you so much....awesome tutorial. I learned so much about the proper way to structure queries and logically break down what they are doing.
-
Because you do not have single quotes around it.
u.username = 'u2' is what it should be.
oh yeah....
the actual code looks like this:
WHERE u.username = ".clean($p_username,'sql')."
I forgot to add those single quotes in there....
thank you....
-
mysql_query($query_playlist) or die ("SQL Was (playlist): " . $query_playlist . "<br />Mysql Returned: " . mysql_error());
thank you...
SQL Was (playlist): SELECT p.name FROM playlists p INNER JOIN user u ON p.userID = u.userID WHERE u.username = u2 AND p.nameHash = Punk-Rock LIMIT 1
Mysql Returned: Unknown column 'u2' in 'where clause'
I don't understand why its saying u2 is a column, when its really a value in a column??
-
Right now I use this if a query fails:
mysql_query($query_playlist) or die (mysql_error());
Is there a way to have it give me more info?
all its saying is:
Unknown column 'u2' in 'where clause'
where u2 is a username....
thanks
-
If I want to allow letters, numbers, spaces and single quotes?
I tried this:
preg_match("#^[a-z0-9 ']+$#i", $value)
and this:
preg_match("#^[a-z0-9 \']+$#i", $value)
neither worked....
I'm blind.....I had the wrong variable in there.....it was something different than $value....
its working now with this:
preg_match("#^[a-z0-9 ']+$#i", $value)
thanks for the help though sasa....
-
If I want to allow letters, numbers, spaces and single quotes?
I tried this:
preg_match("#^[a-z0-9 ']+$#i", $value)
and this:
preg_match("#^[a-z0-9 \']+$#i", $value)
neither worked....
-
sorry, I get confused easily. Having two little kids who keep you up at night makes your brain function at like 60% normal capacity.
Ok, so, I escape it, it turns it into \' but in the database it stores it as ' only.
thanks....
-
You answered your own question. That is the best way to do it, if this is going to actually be a filename, I would not allow it. If it is only stored in a database, it is fine with ' etc. Just escape the data with the mysql function.
No, playlists will not be filenames. They are just going to be in stored in the database.
So, when you mysql_real_escape_string() a value, it converts all single quotes into \'
Does the \' get stored in the database like that? With the backslash?
I'm confused, when you use the escape string(), what gets stored in the database? a single quote or a backslash and single quote?
-
If I wanted to let users include single quotes as part of their playlist names, how would I safely allow them to do that?
ex) $playlist = "60's Rock"
Because, right now, I mysql_real_escape_string() values.
I assume you should always mysql_real_escape_string() any user input, so how would I allow them to safely enter a single quote as part of their playlist name?
-
ok, this flags "Rock Indie"
if(!preg_match('#^[a-zA-Z0-9 ]?$#i', $newPlaylist))
//flag
this does not flag "Rock Indie", but it requires a value:
if(!preg_match('#^[a-zA-Z0-9 ]+$#i', $newPlaylist))
//flag
Why does the question mark flag "Rock Indie"? In the tutorial, it says the question mark allows the pattern 0 or more times....what am I misunderstanding?
-
here's the problem:
if(!preg_match('#^[a-zA-Z0-9 ]+$#i', $newPlaylist));
I left the semicolon after the if statement.....
nevermind...apparently that didn't fix it....it still won't let
"Rock Indie" through....its flagging it....
-
Ok, I redid the routines.....
<?php $newPlaylist = trim($newPlaylist); $newPlaylist = preg_replace('/\\s{2,}/',' ',$newPlaylist); //Replace multiple spaces in between characters with 1 space if(!preg_match('#^[a-zA-Z0-9 ]+$#i', $newPlaylist)); //Check for invalid characters //flag
I set $newPlaylist= "Rock Indie"
its flagging it....
that shouldn't be happening, right? I'm allowing a-z A-Z and 0-9 and spaces....how is this happening?
-
OK this is a bit basic probably BUT
I have 2 recordsetsRS1 RS2
RS1 has one record with column Food1 conataing cheese,ham,toast
RS2 also has column Food2 but with only one food type. I want to filter RS2 so it only shows those records have one of the comma seperate values in it's Food Column
Does that make sense
Thanks
Let me try to clarify:
You want to display rows that have no commas in column Food2?
-
Why do you need to check it, because the following will allow you to have any values in a string:
mysql_real_escape_string($user)
Because, the playlist name will eventually be used as part of a url:
ex) mysite.com/userplaylists/username/playlistnameHash/
I have to make sure it only contains letters,numbers and spaces. All other characters would not be SEO friendly.
except for underscores. But why allow underscores when dashes will do just as well.
-
think your missing
adding A-Z in the brackets gave me a match, I see the case insensitive setting though this still is what was needed for it to work for me with your example,
might want to try asking in the Regex section
I'm going to change it to just check for [a-z0-9 ] case insensitive
before I send it there I will trim it. I'll have a separate check to see if it exists.
You shouldn't need to add A-Z if its case insensitive, right?
-
I'm using this to check a value:
if(!preg_match('#^[a-z0-9](?:[ ]?[a-z0-9])+$#i', $newPlaylist)); //flag
The rules are it can start with a letter or number, can contain a space, and end with a letter or number.
I'm giving it this value: "Road Songs"
and its flagging it.
Is my preg_match correct for my rules?
thanks
I might just be stupid - php/mysql problem. please/thx in advance
in PHP Coding Help
Posted
I'm probably wrong here, but maybe because ladder_$id is not a valid table name?